我在我的表中的列如下:選擇命令SQL
name, company, email, contact, event-day, event-time
我想通過一個SQL命令來選擇從表中的每一行中的某一天的時間列所有相同的時間。
我次區域的1030混合物,1130,1230天是17月和18月
因此,舉例來說,我想看看有多少人已經預訂了1030時隙上5月17日?
我在我的表中的列如下:選擇命令SQL
name, company, email, contact, event-day, event-time
我想通過一個SQL命令來選擇從表中的每一行中的某一天的時間列所有相同的時間。
我次區域的1030混合物,1130,1230天是17月和18月
因此,舉例來說,我想看看有多少人已經預訂了1030時隙上5月17日?
如果你的約會列基於文本:
select *
from tbl
where event-day = '17th-may' and
event-time = '1030';
否則,你就需要使用一個日期字面解釋的功能(如Oracle的TO_DATE)建設要與之比較的日期。
select *
from tbl
where event-day = TO_DATE('2002/05/17') and
event-time = '1030';
只注意到你對MySQL的
select count(*)
from tbl
where event-day = '2002-05-17' and
event-time = '1030';
我該如何計算它選擇的項目數量? – Rob
@Rob,我已經更新了MySQL塊 –
嘗試
SELECT * FROM table_name WHERE event-day='17th-july' AND event-time=1730
這會給你所需的輸出。
試試這個
select COUNT(*) as NumberOfPlaces
from registered
where event-day = '17th-july' and
event-time = '1030';
是此SQL Server,MySQL等? – SOfanatic
你到目前爲止做了什麼? –
你嘗試過什麼嗎? – Shin