I'm running around in circles and have been doing so in the last hours.
I'm doing a select in a table where have all stock of each store and I'm filtering by product id. What i need is: have a list of all stores even if I have no data for that store, but the select only returns 4 stores or less.
Here's an example:
That's the query:
select
store_id, product_id, start_date, quantity
from
stock
where
product_id = 407214
That's the result:
store_id | product_id | start_date | quantity |
2 | 407214 | 2015-05-26 08:32:53 | 10 |
3 | 407214 | 2015-03-16 12:10:00 | 25 |
4 | 407214 | 2015-01-06 11:45:15 | 16 |
7 | 407214 | 2015-05-14 00:00:00 | 8 |
And that's what I want:
store_id | product_id | start_date | quantity |
1 | NULL | NULL | NULL |
2 | 407214 | 2015-05-26 08:32:53 | 10 |
3 | 407214 | 2015-03-16 12:10:00 | 25 |
4 | 407214 | 2015-01-06 11:45:15 | 16 |
5 | NULL | NULL | NULL |
6 | NULL | NULL | NULL |
7 | 407214 | 2015-05-14 00:00:00 | 8 |
I would really need a help, it's driving me crazy!!