0

SELECT *
FROM `engine4_user_fields_values`
WHERE (field_id = 3) AND (value = 'test7') AND (field_id = 4)
  AND (value = 'test7') AND (field_id = 13) AND (value = 'Hemraj')


field_id | value
-----------------------------
3  | test7
4  | test7
13  | Hemraj

How to find this values?

When I use or operator it's showing two values or one value. My requirement is if not found any of this one then can't display.

jarlh
  • 40,041
  • 8
  • 39
  • 58

3 Answers3

0

Like this?

SELECT *
FROM `engine4_user_fields_values`
WHERE 
  (field_id = 3 AND value = 'test7') OR 
  (field_id = 4 AND value = 'test7') OR 
  (field_id = 13 AND value = 'Hemraj')
Pyton
  • 1,262
  • 8
  • 18
0

Hope this helps.

SELECT Value 
FROM `engine4_user_fields_values`
GROUP BY Value
HAVING COUNT(*) >1 
Sandesh
  • 1,016
  • 5
  • 13
0

If you just want to see if all the values are there:

SELECT (CASE WHEN COUNT(*) = 3 THEN 'ALL PRESENT' ELSE 'MISSING FIELD' END)
FROM `engine4_user_fields_values`
WHERE (field_id = 3 AND value = 'test7') OR 
      (field_id = 4 AND value = 'test7') OR 
      (field_id = 13 AND value = 'Hemraj')
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709