bennystromberg
12-23-2003, 11:04 PM
I need help with a SQL-syntax.
Iīm coding a web-application in PHP and Iīm using a MySQL database. My web-application is going to show information about people working at different companies. Each company have their own table in the database (for example Microsoft, IBM, HP) and then I have one table called 'users'. In the companies tables there are two columns: 'firstname' and 'surname'. In the 'users' table there are also two columns: 'username' and 'company'. When a persons logs in to the web-application the code checks which username logged in and I would like to use this code: SELECT firstname, surname FROM (SELECT company FROM users WHERE username='the one who is logged in');
Unfortunately MySQL canīt handle this kind of syntax. Do you have any ideas how I could get around this problem?
Thanks a lot!
Benny
Finland
Iīm coding a web-application in PHP and Iīm using a MySQL database. My web-application is going to show information about people working at different companies. Each company have their own table in the database (for example Microsoft, IBM, HP) and then I have one table called 'users'. In the companies tables there are two columns: 'firstname' and 'surname'. In the 'users' table there are also two columns: 'username' and 'company'. When a persons logs in to the web-application the code checks which username logged in and I would like to use this code: SELECT firstname, surname FROM (SELECT company FROM users WHERE username='the one who is logged in');
Unfortunately MySQL canīt handle this kind of syntax. Do you have any ideas how I could get around this problem?
Thanks a lot!
Benny
Finland