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

SQL-question

Status
Not open for further replies.

wuah

Programmer
Mar 15, 2001
42
DK
I don't know if this is the right forum, but here goes.

Is it possible to match/compare two sql-queries?

I have an SQL-query which includes some "Or" statements and another which includes some "AND" statements.
I'm quering in the same table in the same db, but I really want to get one output where I get the intersection between query 1 and 2. You can sort of say "3 = 1 AND 2". Get m drift?

Some somewhat a beginner in this SQL stuff so I don't know if all this can be described in one SQL-query?

These are the SQL-queries:

strSQL = "SELECT * FROM tblCBtest WHERE"

strSQL = strSQL & " (cb LIKE '" & strTypen & "')"
strSQL = strSQL & " or (cb2 LIKE '" & strTypen & "')"
strSQL = strSQL & " or (cb3 LIKE '" & strTypen & "')"

'-------------------
str2SQL = "SELECT * FROM tblCBtest WHERE"

str2SQL = str2SQL & " (Amt LIKE '" & strAmt & "')"
str2SQL = str2SQL & " AND (Postnr LIKE '%" & strPostnr & "%')"
str2SQL = str2SQL & " AND (Byen LIKE '%" & strByen & "%')"
str2SQL = str2SQL & " AND (Navn LIKE '%" & strNavn & "%')"

==============

Thanks

Rasmus
 
I think I understand what you are asking. You could try working with the IN clause in your where clause using a common unique field using the second select query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top