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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

howto select from one and then select from the other in one statement

Status
Not open for further replies.

ankursaxena

Programmer
Sep 7, 2001
133
US
Hi! i dont know how intutive was my question, i am not sure how to put it in one line..in any case what i want to do is...select(one col.) a no. of rows from one table depending on a condition and have each of the rows selected run another select on another table. i am also getting confused :) ;)
anyhow eg being i have a table called
BuddyList:
column username & column buddy

table Status
columns: username, status

so i wanna select buddy from buddylist where some username='something' then according select username from status based on teh buddy selected and show the status..hope this was more clear.
if someone can give me a better way of looking at it or a solution it woul dbe gr8
-Ankur
plz email me at ankur.saxena@motorola.com
 
Ok, here's what i'm assume'n.
You have two tables ,
table 1 = buddy
table 2 = status

both buddy and stutus has a field call username.

SQL = "SELECT B.first_name,B.lastname,S.status
FROM buddy AS B, status AS S
WHERE B.username = S.username AND
B.username = 'buddyname'
";

output ---
first_name | last_name | status
--------------------------------------
john smith not_friend_anymore


hope this is what you wanted.

cheers
Ken
devnull22

--
Apparently if you play the Windows NT CD backwards you hear satanic messages. If you think that's bad, play it forwards and it installs Windows NT !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top