I need to restrict access to other table id's by making a check against an (id) of a table named users and then check that the (user_id) of another table is the same i.e


id username password


id somedata user_id

if table1 id is the same as table2 user_id then show table2 contents but only show the contents of table2 where the user_id exists and still use the id row of table2 to display contents in a url like ?id=12 only if its the users data if not frow an error

How would I go about this I have tried and tried but no joy

I have some code setup that I been trying I can post if like.

6 Years
Discussion Span
Last Post by mbhanley

You need to use an INNER JOIN.

Something like...

SELECT t1.id, t2.somedata FROM table1 AS t1 ON table2 AS t2 INNER JOIN t1.id = t2.user_id WHERE t1.id = $id

I get it now.. how confusing, I was stuck thinking I needed to php to check it lol.
How simple I never thought you could use an id as another id with a query nice one for your help on this.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.