如何填补行之间的空白?我正在使用表格日历,但我的查询似乎不正确。结果没有显示差距..
SELECT calendar.datefield, t2.*
FROM store_relation t1,store t3, store_product t2
RIGHT JOIN calendar ON (DATE(t2.created) = calendar.datefield)
WHERE (calendar.datefield BETWEEN ('2012-07-15') and ('2012-07-20'))
AND t1.id_store_a = 1
AND t1.id_store_b = t2.id_store
AND t3.id = t2.id_store
AND t2.id_product = 11
ORDER By t2.price
结果:
datefield | id_product | id_store | created
2012-07-15 1 1 2012-07-15
2012-07-18 1 1 2012-07-18
2012-07-20 1 1 2012-07-20
2012-07-20 1 1 2012-07-20
我在等结果
datefield | id_product | id_store | created
2012-07-15 1 1 2012-07-15
2012-07-16 null null null
2012-07-17 null null null
2012-07-18 1 1 2012-07-18
2012-07-19 null null null
2012-07-20 1 1 2012-07-20
2012-07-20 1 1 2012-07-20