Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested selects in mySQL with PHP?

Status
Not open for further replies.

QuietFire

Programmer
Feb 25, 2003
12
US
I can find a longer way around my problem, but when I was doing a lot of asp/MS SQL stuff I sued to do write some pretty specific queries. I tried this through phpMyAdmin and received syntax errors. I guess what I want to know more than anything is, is it possible in php/mysql?

SELECT userpermissions.location_id ,locations.loc_name FROM locations WHERE userpermissions.location_id IN (SELECT userpermissions.userid FROM userpermissions WHERE userpermissions.userid = '4')

like I said, I can get there in a round about way, but it seams something like this should be possible.

Thanks in advance,

Charlie
 
Code:
SELECT userpermissions.location_id ,locations.loc_name FROM  locations WHERE userpermissions.location_id IN (SELECT userpermissions.userid FROM userpermissions WHERE userpermissions.userid = '4')

Don't you miss anything in your "FROM"-Part?

Code:
SELECT userpermissions.location_id ,locations.loc_name FROM  locations, [red]userpermissions[/red] WHERE userpermissions.location_id IN (SELECT userpermissions.userid FROM userpermissions WHERE userpermissions.userid = '4')

I thought you must specify all your tables, but I'm not an SQL-guru
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top