且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Mysql复杂where子句

更新时间:2023-10-23 14:32:52

您当前的查询是矛盾的,因为单个行永远不能匹配WHERE子句。我假设你想要这样的东西。

Your current query is contradictory as a single row can never match the WHERE clause. I assume you want something like this.

SELECT product_id
FROM table 
WHERE (key='free_shipping' and value='yes') or (key='price' and value='5')
GROUP BY product_id
HAVING COUNT(DISTINCT key) = 2