0

Is it possible to have Having and Or Where to function like where field = 'text' or field2 = 'text'

Basically I'm trying to create a function to be used to filter all the columns on a html table. For the data using SUM() I need to use HAVING if I filter using all columns the where clause will be like where name like '%asdf%' or age like '%asdf%' or having SUM(quantity) like '%asdf%' group by id

  • 1
    Unclear. WHERE and HAVING clauses are not dependent and may present in the query at the same time. – Akina Sep 15 '21 at 08:22
  • I want it to be OR not AND. I want it to display the results from the WHERE and display the results from the HAVING. is it possible? – Sidney Medrano Sep 15 '21 at 08:44
  • Impossible. Use 2 queries combined with UNION. – Akina Sep 15 '21 at 08:47
  • Ok I just found the answer I'm looking for I can replace the where with having. Thanks – Sidney Medrano Sep 15 '21 at 08:56
  • WHERE is processed before grouping, HAVING - after. I.e. the conditions in these clauses have different grouping level, so you cannot combine them in one expression. – Akina Sep 15 '21 at 09:03

0 Answers0