[英]MySQL INNER JOIN and SELECT
I am working on a small calendar application and practicing MySQL queries for finding available time slots based on the answer provided by flaschenpost 我正在开发一个小型日历应用程序,并根据flaschenpost提供的答案练习MySQL查询以查找可用的时隙
mysql show time slots avaliable and time slots busy from table
mysql显示可用的时隙和表中的时隙忙
I am studying the query step by step. 我正在逐步研究查询。 I ran the query below separately to see what it returns exactly.
我分别在下面运行查询以查看其返回的确切信息。
(select 1 as place, 'Free' as name union select 2 as place, 'Booked' as name ) as d
inner join bookingEvents b
However, I got a syntax error: 但是,出现语法错误:
ERROR 1064 (42000): You have an error in your SQL syntax;
错误1064(42000):您的SQL语法有错误;
I also tried the query below but still getting the same error. 我也在下面的查询中尝试过,但仍然收到相同的错误。
select (select 1 as place, 'Free' as name union select 2 as place, 'Booked' as name ) as d
Please help. 请帮忙。
Those are tables that belong in the from
portion of your query. 这些表属于查询的
from
部分。
Do this: 做这个:
select
*
from
(select 1 as place, 'Free' as name union select 2 as place, 'Booked' as name ) as d
inner join bookingEvents b
You are missing a from
in the 2nd subquery so you are executing a select statement in none of the table. 您在第二个子查询中缺少
from
,因此您没有在表中执行select语句。
On the 2nd query you have mentioned just put * from
as 在您提到的第二个查询中,只需将
* from
为
select * from (select 1 as place, 'Free' as name union select 2 as place,'Booked' as name ) as d
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.