TABLE1
ID | DATE Ordered
a | 10-06-2012 | 1
b | 07-07-2012 | 1
c | 10-06-2012 | 0
TABLE2
ID | OrdersID
a | 001
b | 002
c | 003
TABLE3
OrdersID | Items |
001 | 5 |
002 | 3 |
003 | 7 |
I have three tables and I would like to search the DATE in TABLE1 e.g. 10-06-2012 and Ordered e.g. 1 and return the ID ‘a’.
In Table2 I would like it to use Table1’s result to get the OrdersID
And in Table3 I would like it to use Tables2’s result to return Items
ID is common in both tables.
Wich RDBMS are you using, MS SQL Server, MySQL, Oracle? Doing some research on how to handle tSQL, create queries, use Joins, etc, will not harm you.
In case you are using MS SQL Server here is a sample of what can be done with the data you provided. Be carefull, nested queries can be awfully slow, check your indexes, primary keys, etc.