MySQL中的这个多选SQL有什么问题:
select *
from license
where license.expirydate between (
(select monthrange.monthstart from monthrange where id = 1)
and
(select monthrange.monthend from monthrange where id = 1)
)
答案 0 :(得分:1)
以下是您的查询:
select *
from license
where license.expirydate between ((select monthrange.monthstart from monthrange where id = 1) and
(select monthrange.monthend from monthrange where id = 1)
)
between
的参数不应该在括号中。试试这个:
select *
from license
where license.expirydate between (select monthrange.monthstart from monthrange where id = 1) and
(select monthrange.monthend from monthrange where id = 1)
当然,您也可以将其表达为join
。这个答案仅用于评论语法错误:
select l.*
from license l join
monthrange m
on l.expirydate between m.monthstart and m.monthend and
m.id = 1;