我有 2 张桌子。client (client_id, client_name, client_lname)
Order_Date和orders(Order_Id,Client_Id,Total_Amount,Order_Date,Order_Time,Order_Status)
Order_Time 的类型是 varchar。
我必须显示两个日期和时间之间的记录。我写了这个查询:
SELECT
o.Order_Id,
c.client_name,
c.client_lname,
o.Total_Amount,
o.Order_Date,
o.Order_Time
FROM orders AS o
JOIN client AS c
ON o.Client_id = c.Client_id
WHERE (o.Order_Date between '01/01/2013' and '22/01/2013' )
AND (o.Order_Time between '17:41:59' and '20:42:04')
AND o.Order_Status='1'
ORDER BY o.Order_Id
例如:
Order_id Client_id Total_Amount Order_Date Order_Time Order_Status
120 32 60 01/01/2013 12:44:15 1
121 32 60 01/01/2013 12:47:51 1
122 32 90 01/01/2013 18:16:41 1
127 32 60 01/01/2013 18:34:31 1
128 32 90 01/01/2013 18:35:19 1
129 32 120 19/01/2013 8:12:04 1
130 32 90 19/01/2013 15:33:16 0
131 33 90 19/01/2013 15:40:03 1
我想显示从 01/01/2013 12:40:00 到 19/01/2013 09:00:00 的记录。所以它应该显示 6 条记录。要写什么查询