I have a set of three tables:
Dining_Tables
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
| dining_table | int (11) | NO | PRI | NULL | |
| bus_boy | varchar (35) | NO | | NULL | |
| waiter | varchar (35) | NO | | NULL | |
| server | varchar (35) | NO | | NULL | |
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
Poker_Tables
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
| poker_table | int (11) | NO | PRI | NULL | |
| dealer | varchar (35) | NO | | NULL | |
| pit_boss | varchar (35) | NO | | NULL | |
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
Computer_Tables
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
| computer_table | int (11) | NO | PRI | NULL | |
| programmer | varchar (35) | NO | | NULL | |
+ -------------------- + -------------- + ------ + ----- + --------- + ------- +
Each of these lines has a globally unique identifier of the table that is associated with it: ( dining_table, poker_table, computer_table) in the other column stores the name of the first and last person performing the roll.
In my model, one person can do several things. For example, Joe Smith could pretend to be sitting in computer_tableas a programmer, sitting in poker_tableas a dealer and waiting on dining_tableas a waiter.
My question is: I need a request that will allow me to get everything table_idsfor this person. In particular, the query will then return the list table_idsthat Joe Smith is currently on.
- :
select dining_table from Dining_Tables where
bus_boy = "Joe Smith" or
waiter = "Joe Smith" or
server = "Joe Smith";
select poker_table from Poker_Tables where
dealer = "Joe Smith" or
pit_boss = "Joe Smith";
select computer_table from Computer_Tables where
programmer = "Joe Smith";
, , , . ?