php - Select data from logged in user with a mySQL query -


i have nodes, nodes belongs company. users belong company can view nodes.

portion of database , wished relations

the mysql query i'm trying use this:

select nodes.mac, companys.companyname users, nodes, companys users.id='2' , nodes.owner=users.company 

it works - shows 1 node every user. want show $_session user nodes.

you can using inner join find nodes single user way using on , where clause.

select nodes.mac,    companys.companyname users  inner join companys on   users.company=companys.id inner join nodes on   companys.id=nodes.owner   users.id=2 

here user.id should $_session array value contains current user's id


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -