如何解决这个多条件的条件(field_ids和values)?

时间:2016-05-21 08:14:56

标签: mysql sql

选择值= Hemraj和value = pal,其中field_id = 3且where_id = 4;



how to solve this query?

table structure :

field_id = 3 value = Hemraj
field_id = 4 value = Pal
field_id = 3 value = Subhankar
field_id = 4 value = Chaole
field_id = 3 value = Suman
field_id = 4 value = Pal
field_id = 3 value = Akash
field_id = 4 value = Dutta
field_id = 3 value = Hemraj
field_id = 4 value = Pal




3 个答案:

答案 0 :(得分:2)

您也可以使用IN运算符

SELECT value FROM engine4_user_fields_values 
where field_id IN (3,4,5,6)

答案 1 :(得分:0)

这个怎么样?

SELECT value FROM engine4_user_fields_values 
where field_id=3 
   or field_id=4 
   or field_id=5 
   or field_id=6 ....

答案 2 :(得分:0)

多个WHERE条件。

SELECT value FROM engine4_user_fields_values 
    WHERE field_id1=3 AND field_id2=4 AND ....

链接

中给出了一个很好的例子

Multiple where conditions