Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to query two tables? sqlnoob here

Author  Topic 

jatrix32
Starting Member

49 Posts

Posted - 2010-09-13 : 12:41:59
Here is what I am trying to do:
I am using a variable from my web page to find information between 2 tables.

I am using the variable to find a specific record in the subscription table. Then based on the results, using the info that was obtained from the SUBSCRIPTION table, matching the SUBSCRIPTION.sub_id against the PHONENUMBERS.sub_id and return those results.

I know my SQL is not right.

Select *
From SUBSCRIPTION,PHONENUMBERS
Where SUBSCRIPTION.sub_email2 = #variable#
And SUBSCRIPTION.sub_id = PHONENUMBERS.sub_id

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-14 : 05:11:46

Select * From PHONENUMBERS as t1 where
exists(select * from SUBSCRIPTION where sub_email2 = #variable#
And sub_id = t1.sub_id)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -