Skip to content
Advertisement

LIKE group_concat with where clause

i am using Like in group concat & i want to get all modules attached to client even if it does not match to LIKE, i know that that i can do that with HAVING but i don’t want to use HAVING, any solution with WHERE or in join condition ?

Any suggestions on how to get my expected result??

These are some basic tables and the query i tried along with results i get and the result i really wanted

Tables

Query:

Results:

Advertisement

Answer

This is possible without HAVING by using EXISTS:

But this is less efficient, and more verbose so offers no advantage whatsoever. I expect your reasons for using HAVING are largely unfounded, and the approach I would personally take is with a conditional count in the HAVING clause:

Example on db<>fiddle

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement