Sample Header Ad - 728x90

SELECT COALESCE with subselects is throwing error 'Operand should contain 1 column'

0 votes
1 answer
370 views
I made this query: SELECT COALESCE( (SELECT * FROM JournalEntryTitleAndContent jetc WHERE jetc.language_id = 2 AND jetc.journalentry_id = 1 LIMIT 1), (SELECT * FROM JournalEntryTitleAndContent jetc WHERE jetc.language_id = 1 AND jetc.journalentry_id = 1 LIMIT 1), (SELECT * FROM JournalEntryTitleAndContent jetc WHERE jetc.journalentry_id = 1 LIMIT 1) ) Its purpose is to check if there is a row present with language_id 2 (thats the preferred language). If that is not present then the coalesce should try to find the row with the fallbacklanguage with id 1, if that returns null as well then it should return the first row it can find where journalentry_id = 1. When I execute this statement in workbench i get Error Code 1241: Operand should contain 1 column(s) Can i not return a row as a single value from coalesce? If not what should i use instead then? Should i use CASE or IFNULL() instead? Thank you
Asked by Maurice (147 rep)
Mar 3, 2020, 11:09 AM
Last activity: Mar 3, 2020, 11:38 AM