1
Hello, I am trying to make a query for an order system for a restaurant. My tables are arranged as follows:
I need to bring all tables (regardless of whether they have a request or not) if they have a status 0 order, these requests must come. If there is no request(s) with status 0 for that particular table, the request must come null.
For example:
Tables:
[1,1]
[2,1]
[3,1]
[4,1]
Orders:
[1,1,0]
[2,2,1]
[3,3,1]
[4,4,0]
[5,4,1]
[6,3,-1]
[7,2,0]
Expected result:
Table.id | Order.id
1 |1
2 |null
3 |null
4 |4
2 |7
Search for Outer Join https://dev.mysql.com/doc/refman/5.7/en/outer-join-simplification.html
– Motta