Hi
I'm trying to make a query which selects one set of results but if that set is empty, will fall to a backup which is looser. It's for a search function.
When I tried the method below (with IFNULL), it seems to run the second query but only return one result but the second query returned a list of 50+ results when run alone.
Perhaps there is an alternative method? Or am I on the right track but have some errors...?
Thanks for your help! Here is the SQL:
[code=sql]
SELECT * FROM people
WHERE pk
IN (
IFNULL(
(
select GROUP_CONCAT(pk )
from people
where name="henryrhen ryr" group by name
),
(
select GROUP_CONCAT(pk )
from people
where name like '%henry%' group by name
)
)
)
[/code]
I'm trying to make a query which selects one set of results but if that set is empty, will fall to a backup which is looser. It's for a search function.
When I tried the method below (with IFNULL), it seems to run the second query but only return one result but the second query returned a list of 50+ results when run alone.
Perhaps there is an alternative method? Or am I on the right track but have some errors...?
Thanks for your help! Here is the SQL:
[code=sql]
SELECT * FROM people
WHERE pk
IN (
IFNULL(
(
select GROUP_CONCAT(pk )
from people
where name="henryrhen ryr" group by name
),
(
select GROUP_CONCAT(pk )
from people
where name like '%henry%' group by name
)
)
)
[/code]