Hi,
Is it possible to use a select statement inside the where clause?
I have two tables:
- users
- profiles
Each profile contains a field called userid (which links the profile to the user).
Lets say I want to retrieve the profile of a user using the user's username:
How could I combine these two commands into one command (so that I only have to query the database once from my code)?Code:theuserid = SELECT userid FROM users WHERE username=theusername profile = SELECT [...] FROM profiles WHERE userid=theuserid
Is this possible?
Code:SELECT [...] FROM profiles WHERE (SELECT userid FROM users WHERE username=theusername)



Reply With Quote




Bookmarks