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
  • 42,561
  • 8
  • 45
  • 63

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,291
  • 8
  • 19
0

Hope this helps.

SELECT Value 
FROM `engine4_user_fields_values`
GROUP BY Value
HAVING COUNT(*) >1 
Sandesh
  • 1,036
  • 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,242,037
  • 58
  • 646
  • 786