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

Combining 2 queries 1

Status
Not open for further replies.

scotsql

Technical User
Jan 18, 2005
9
GB
Hi all, i hope i am entering this in the correct forum. I have a query which uses odbc to connect to an as400 system. I need to specify to only pull records which have certain usernames (a list of about 200) the only way i have been able to do this is to specify each user in the sql. is it possible to specify these from a list somewhere else? possibly combining 2 queries?

hope i have not been 2 vague.

regards

bob
 
Bob, the correct answer depends on the capabilities of the ODBC driver you are using. Without further information, it might be that a simple join could generate the correct resultset. Or, if you have some more dynamic requirement, you might want to use a subquery. Most ODBC drivers support joins, but not all ODBC drivers support subqueries (the ODBC standard does not demand this).

Can you provide information about the two queries you are presently using (without the list of 200 usernames, though [bigsmile])

Tom Morrison
 
scotsql,
Unless there is a common between the userNames, It's a long process to type each userName into a sql query such as ('tol1035','sol2045','erm3947','wes3002')
So I suggest pasting a list of just the names you want to query into MSWORD and build a macro that would normalize the names into the proper syntax for SQL.

From:
tol1035
sol2045
erm3947
wes3002
To:
'tol1035','sol2045','erm3947','wes3002'

Then paste this into your sql statement and execute...
tav
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top