我有一张table如下:
在这里,我想运行一个如下的查询:
SELECT model_id
FROM model_attributes
WHERE ((attributes_id=2 and attributes_value='32mb')) AND ((attributes_id=4 AND attributes_value='5.00 inch') OR (attributes_id=4 and attributes_value='6.00 inch')) AND ((attributes_id=5 and attributes_value='here') OR (attributes_id=5 and attributes_value='asfdsdf'))
返回模型ID 8, 9
. 但似乎我不能在同一个字段中设置多个条件。
我也试过解决办法,在这篇帖子里还是没什么!我怎样才能得到这个结果?我用的方法 AND
子句不正确,但类似于我要在查询中实现的逻辑。
2条答案
按热度按时间2cmtqfgy1#
制造
and
至or
就像上面我想的那样and
逻辑上是错误的cwxwcias2#
您要求的行的属性是2、4和5,这永远不会是真的。
试试这个: