Return values so this empty MYSQL

0

Greetings I am doing a query in MYSQL but if it is empty the where in does not return values to me.

SELECT objects.*, GROUP_CONCAT(mvalues.value SEPARATOR ", ") as value, 
GROUP_CONCAT(mdescriptor.name SEPARATOR ", ") as name FROM objects JOIN 
metadata_values mvalues ON mvalues.idObject = objects.idObject JOIN 
metadata_descriptors mdescriptor ON mvalues.idDescriptor = 
mdescriptor.idDescriptor WHERE objectType = 'EMBED' AND mdescriptor.name 
IN ('Year Created', 'Thumbnail Patch', 'Latlng') AND objects.idObject IN 
(SELECT idObject FROM metadata_values WHERE value IN ('Adornment')) GROUP 
BY objects.idObject LIMIT 0, 5

If this part of sql code is empty, it does not return values

objects.idObject IN (SELECT idObject FROM metadata_values WHERE value IN ('Adornment'))
    
asked by Arielperez 13.09.2018 в 16:30
source

1 answer

0

It will not return anything if you leave the where in vacuum, I do not know where you are setting the condition, but you should condition the query that if there are no filters do not use the condition, or simply separate in several where the "in" and pass 1 = 1 if filters are not needed.

    
answered by 13.09.2018 / 18:04
source