PHP查询 - 合并在哪里条件

时间:2017-01-28 16:03:48

标签: php mysql coalesce

在mysql客户端中,使用此条件的查询工作正常,但是当将此查询放在php页面中时,无法正常工作:

变量是$ _REQUEST:

SELECT * FROM table_name
WHERE 1=1
AND idbook = '$idbook'
AND book_year between coalesce('$year',book_year ) and coalesce('$year',book_year ) 

如果删除此行AND book_year between coalesce('$year',book_year ) and coalesce('$year',book_year ),查询工作正常。

如何解决?

0 个答案:

没有答案