I am trying to write a query that will select two fields from table 1 and one field from table 2 based on a user_id number that is passed to it in a variable named $user_id.
I tried the following but it is not the right syntax - bombing on me:
$query = "select t1.username t1.Temp_pwd t2.email from users t1, directory t2 where t1.user_id='$user_id' and t1.user_id = t2.user_id";
When I try running it in phpMyAdmin using an actual user_id instead of the variable I get the following error:
Error
SQL query: Documentation
SELECT username Temp_pwd email
FROM users t1, directory t2
WHERE t1.user_id = '1001'
AND t1.user_id = t2.user_id
LIMIT 0 , 30
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'email from users t1 , directory t2 where t1 . user_id = '1001' and t1 . user_id ' at line 1
Any ideas on what is mucked up?