-3

i want to run sql query (mysql) and i have multiple condition in WHERE & also multiple condition in HAVING,
SQL apply "AND" between WHERE & HAVING, i want to apply "OR" between.

WHERE Condition 1, Condition 2 .... Condition N
{{OR}}
HAVING Condition 1, Condition 2 .... Condition N

  • 2
    `HAVING` operates on aggregate rows while `WHERE` operates on single rows. It would be better you include the whole SQL statement since the question doesn't make too much sense as it is. – The Impaler Dec 01 '21 at 02:46
  • The where clause first limits the rows, then the grouping occurs on the rows filtered by where, then finally the having clause filters those grouped rows by filtering on the totals. – Jason Goemaat Dec 01 '21 at 02:49

1 Answers1

1

The only option that I can see to solve your problem is to separate the query and apply UNION DISTINCT to remove the duplicated results. The solution could be something like:

SELECT * FROM t1 WHERE ...

UNION DISTINCT

SELECT * FROM t1 HAVING ...
Nathan
  • 449
  • 1
  • 7
  • 23