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

Two queries to one sql-string 1

Status
Not open for further replies.

FinnK

Programmer
Jun 26, 2008
4
DK
How do I rewrite these two queries to one sql string?

q1:
SELECT bID, b1, b2, b3, b4
FROM T1 WHERE b3=2;

q2:
SELECT T2.aID, T2.a1, T2.a2
FROM T2 LEFT JOIN T1 ON T2.aID = T1.b3
WHERE (((T1.b3) Is Null));

q3:
SELECT ?????

TIA
Erik
 
What do you want to do ????

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

When I run q2 - that uses q1 - it gives me a recordset.
But I need to have only one query that gives me the same recordset.

/Erik
 
I don't see a reference to "Q1" in Q2.

Is it being called "T1" or "T2"?
 
Sorry. I made a mistake.
This is the correct q2.

q1:
SELECT bID, b1, b2, b3, b4
FROM T1 WHERE b3=2;

q2:
SELECT T2.aID, T2.a1, T2.a2
FROM T2 LEFT JOIN q1 ON T2.aID = q1.b3
WHERE (((T1.b3) Is Null));
 
Code:
SELECT T2.aID, T2.a1, T2.a2
FROM T2 LEFT JOIN 

(
SELECT b3 FROM T1 WHERE b3=2
) As X 

ON T2.aID = X.b3

WHERE X.b3 Is Null
 
Hi Golom

Just as I needed.
Thanks very much.

/FinnK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top