以下SQL代码返回,选中的所有内容均为NULL且event_size为0.我的表已根据以下条件正确设置。我在这做错了什么?谢谢你的帮助
SELECT table_one.event_id AS event_id, table_one.event_name AS event_name, table_one.event_address AS event_address, COUNT( table_two.user_id ) AS event_size
FROM table_one
JOIN table_two
ON table_one.event_id = table_two.event_id
WHERE (
table_one.event_start_date = '5/10/2012'
OR table_one.event_mid_date = '5/10/2012'
OR table_one.event_end_date = '5/10/2012'
)
ORDER BY event_size DESC
答案 0 :(得分:0)
尝试添加group by子句:
group by table_one.event_id, table_one.event_name, table_one.event_address
这应该做你想要的。
答案 1 :(得分:-1)
始终使用其中一种通用日期格式而非区域日期格式。
YYYYMMDD或YYYY-MM-DD