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)
                                 )


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;

10-04 12:38