I have two tables in a database. Table 1 includes an order number which could be NULL. Table two contains all order data (including the order number).
Now I want to select all columns from table 1 and all order data from table two. So if a certain entry in table one doesn't contains this order number, all other columns should be null. But if it does contain an order number I want it to be linked to the second table and have these data selected.
Output should be something like:
column1tab1 column2tab1 order_number product amount
xx yy 123 p1 2
xx yy 456 p3 4
xx yy NULL NULL NULL
xx yy 789 p2 1
etc...
I tried different things, but I only get all the rows with an order number or all with null, but I can't get them both at the same time. Does someone know a solution, so I can do this in one query?