Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

SQL Query Help to Select a table based on ID

$
0
0

Hello Community,

Can someone help me compile a query that will select a table based on item in a row.

We have a database that is updated daily with various tables.

At the moment the database has Three tables. TableOne has a load_id of 1111, TableTwo has a load_id of 1122, and TableThree has a load_id of 1133.

I'm trying to write a query that will select a table in the database based on the value of the load_id number. So, if TableThree arrived in the database with LOAD_ID 1133 before before TableTwo with LOAD_ID 1122 I 'don't' want my query to select TableThree, but wait until TableTwo has arrived in the database before selecting TableThree. Likewise, if table TableTwo arrived in the database with LOAD_ID 1122 before TableOne with LOAD_ID 1111 I don't want my query to select TableTwo before TableOne.

The best way I think I can explain it is like this:

select * from TableThree where LOAD_ID = 1133, but only if in a previous select statement I checked for LOAD_ID 1122 from a previous table(TableTwo in this case) and successfully found LOAD_ID = 1122.

I hope I have described the question sufficent for a good response

You're help is very much appreciated.

Carlton


carlton


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>