I want a select that if/exists it returns the ‘link’ value instead of regular output.
so instead of ‘1’ it returns the ‘link’
Is that possible?
SELECT IF(
EXISTS(
SELECT link FROM modules WHERE module='license'
), 1, '/dashboard/'
)
>Solution :
Use aggregation with MAX() (or MIN()):
SELECT COALESCE(MAX(link), '/dashboard/') link
FROM modules
WHERE module = 'license';
If that specific link does not exist in modules then MAX() will return null in which case COALESCE() will return '/dashboard/'.