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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 query help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-06-21 : 05:43:45
I have 3 relavant tables

customer

customerid
name
mytimestamp


offers
offerid
offer

customerofferlink
id
customerid
offerid

Any way in one sql that I can combine these to do a statment pulling up all names on date x where offerid is customerofferlink table has the offerid that I am choosing

I'm looking if possible for a simple sql statement
for example in asp I would do

sqloffers="SELECT customerid from customerofferlink  where offerid=" & offerid
openrs rsoffers,sqloffers
do while not rsoffers.eof
sql="select * from customer where customerid=" & rsoffers("customerid")
openrs rs,sql
response.write rs("name")
closers rs
rsoffers.movenext
loop
closers rsoffers

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-21 : 05:50:46
Do you want to do that in a single query?
Try this
select C.* from customer C inner join customerofferlink  CL
on C.customerid=CL.customerid


Madhivanan

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

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-06-21 : 05:57:13
yes i wanted to try in one query -- the tricy thing to the above is I want to add a where offerid=1 (tying also the offer table in)
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-06-21 : 12:17:38
otherwise can someone help me with how to do this in an stored procedure to return just the name with the offer in the where statement?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-21 : 12:29:34
Do us a favor, and follow the instruction in the hint below.

Post those things and you'll get your answer in 5 minutes...



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -