嗨朋友们,我不知道查询给定日期的查询在给定日期字段中不存在 在mysql .can任何人帮我发现我有两张桌子1.Marriage Hall和Booking hall id是大厅表中的主键和预订表中的外键。如何加入两个表。我的问题是1.在2013年1月15日之前找到可用的婚姻殿堂
booking_From booking_to
2012-10-12 2012-10-15
2012-10-17 2012-10-19
查看指定日期' 2012-10-12'并不存在于日期
之上答案 0 :(得分:1)
答案 1 :(得分:0)
Here, we are find out date betwwen range of date or not.
If any record is exists then we count no of record is greater then o then date is exists otherwise date is not exists using case function :
select (case when count(*) <=0 then 'Date is not exists' else 'Date is exists' end) as
'exists' from given_date where `From` >= '2012-10-12' and `to` <= '2012-10-12'
答案 2 :(得分:0)
select * from yourtable where `from`='2012-10-12' or `to`='2012-10-12';
答案 3 :(得分:0)
您可以使用OR条件运算符
SELECT * FROM yourTable WHERE FROM = YourDate OR To = YourDate
答案 4 :(得分:0)
SELECT
CASE DoesExist
WHEN 1 THEN 'Exists'
ELSE 'Doesnt Exist'
END AS 'Exists or not?'
FROM
(
SELECT 1 AS DoesExist
FROM tAble
WHERE EXISTS
(
SELECT Date
FROM Table WHERE `FROM` >= '20121012' AND `To` <= '20121012'
)
) t