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

Query that prompts for Table

Status
Not open for further replies.

DanAuber

IS-IT--Management
Apr 28, 2000
255
FR
I have two tables with identical field names - let's call them LIVE_DATA and TEST_DATA.

I want to run an SQL that prompts the user to choose TEST or LIVE. If they choose LIVE, then the SQL: Select * from LIVE_DATA is run, and if they choose TEST the the SQL: Select * from TEST_DATA is run.

Can anyone help me with a simple way to do this ?

Thanks for any help

Dan

 
There is no simple way to do this. Create a union query:
== quniData ====
SELECT "L" as TableName, *
FROM LIVE_DATA
UNION ALL
SELECT "T" , *
FROM TEST_DATA;

Then create another query based on the union query:
SELECT *
FROM quniData
WHERE TableName =[Enter L for Live or T for Test];


You

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
something like this (SQL code) ?
SELECT * FROM (
SELECT 'LIVE' AS
, A.* FROM LIVE_DATA AS A
UNION ALL SELECT 'TEST', A.* FROM TEST_DATA AS A
) AS U
WHERE U.Table = [Enter LIVE or TEST]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top