Select row if other row is empty
Posted: Mon Aug 21, 2006 12:15 am
I have a table that holds 'additional information'. The user can put in a row for each language available.
What I want is that if someone is browsing in French and they go to the page they view the 'additional information' in french. That works fine but...
I want that if there is no additional information for that page in french then it to just default to english or whatever other language I have set as default. How do I do that in 1 query? Right now I just have:
I want to add something like:
IF lai.Information for language abbreviation 'LANGUAGE_CODE' is empty, select where l.Abbreviation = 'DEFAULT_LANGUAGE_ABBREVIATION'
How is this done?
What I want is that if someone is browsing in French and they go to the page they view the 'additional information' in french. That works fine but...
I want that if there is no additional information for that page in french then it to just default to english or whatever other language I have set as default. How do I do that in 1 query? Right now I just have:
Code: Select all
SELECT
lai.Information
FROM
listing_additional_information AS lai
LEFT JOIN
languages AS l
ON
l.Id = lai.fkLanguageId
WHERE
lai.fkListingId = '.$Id.'
AND
l.Abbreviation = 'LANGUAGE_CODE'
IF lai.Information for language abbreviation 'LANGUAGE_CODE' is empty, select where l.Abbreviation = 'DEFAULT_LANGUAGE_ABBREVIATION'
How is this done?