I have a problem with my query results. I have 2 tables that I want to join with specific join to get all the informations about it and a or condition that doesnt include second table. There is my tables :
main_orders:
id | destination
----------
1 | London
2 | Germany
2 | Netherland
3 | Polska
4 | JP
includes:
id | rel_id
----------
1 | 2
1 | 3
here id number 1 is the main order and it also covers the rest of the orders show as in the second table with rel_id
i want to select the order details of id 1 from main_orders and also the orders that relate to this id
my query is,
SELECT a.id FROM main_orders a, includes b
where (a.id = 1) OR (b.id = 1 and a.id = b.rel_id)
it works only when there is any relative orders in the second table, please help the result should be as follows
RESULTANT ROWS:
id | destination
----------
1 | London
2 | Germany
2 | Netherland
3 | Polska
Thanks