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

sql query problem

Status
Not open for further replies.

KowCiller

Programmer
Aug 5, 2002
10
0
0
US
Hello all!

Hopefully someone here can help me with this. I'm a newbie when it comes to building sql queries.

I have two tables, tblReport and tblUser
*both tables have a corresponding rpt_id
*tblReport has a create_id
*tblUser has a user_id

I would like to grab all rows out of tblReport where create_id = "Me" and also grab all rows out of tblUser where user_id = "Me" but only if the rpt_id (in tbluser) does not already appear in the rows I have grabbed.

So basically i want all of the specific create_id's and add to them all the user_id's as long as the rpt_id that the user_id refers to has not already been grabbed.

hopefully that makes sense... hehe

Thanks for the help!

Aaron.
 
select tbluser.* , tblreport.* from tblreport
where tblreport.create_id = "Me"
join tbluser
on
tbluser.rpt_id = tblreport.rpt_id
where tbluser.create_id="Me" and (select distinct tbluser.rpt_id from tbluser)
orderby tbluser.rpt_id



check this out. I heaven't checked it but this is probably what you need

 
select tbluser.* , tblreport.* from tblreport
where tblreport.create_id = "Me"
join tbluser
on
tbluser.rpt_id = tblreport.rpt_id
where tbluser.create_id="Me" and (select distinct tbluser.rpt_id from tbluser)
orderby tbluser.rpt_id



check this out. I heaven't checked it but this is probably what you need

bye
miq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top