我正在开发一个小型日历应用程序,并根据flaschenpost提供的答案练习MySQL查询以查找可用时间段
mysql show time slots avaliable and time slots busy from table
我正在逐步研究查询。我单独运行下面的查询,看看它究竟返回了什么。
(select 1 as place, 'Free' as name union select 2 as place, 'Booked' as name ) as d
inner join bookingEvents b
但是,我遇到了语法错误:
错误1064(42000):您的SQL语法出错;
我也尝试过以下查询,但仍然遇到同样的错误。
select (select 1 as place, 'Free' as name union select 2 as place, 'Booked' as name ) as d
请帮忙。
答案 0 :(得分:3)
这些是属于查询from
部分的表。
这样做:
select
*
from
(select 1 as place, 'Free' as name union select 2 as place, 'Booked' as name ) as d
inner join bookingEvents b
答案 1 :(得分:2)
您在第二个子查询中缺少from
,因此您在任何表中都没有执行select语句。
在您提到的第二个查询中,只需将* from
设为
select * from (select 1 as place, 'Free' as name union select 2 as place,'Booked' as name ) as d