I have a query like this:
SELECT COALESCE(MAX(german),"DEFAULT") from translate_content WHERE english = :englishContent0 UNION ALL
SELECT COALESCE(MAX(german),"DEFAULT") from translate_content WHERE english = :englishContent1 UNION ALL
SELECT COALESCE(MAX(german),"DEFAULT") from translate_content WHERE english = :englishContent2
With the idea that if a value is not found then it will return the value "DEFAULT". My problem is that this query works fine when I run it directly in the database, but when I try it in PHP I get an error saying "undefined index: "german".
I am using MySQL and PHP 5.5.11. I'm sorry if this isn't enough information, but I don't know what else to provide (but ask and I will deliver!)
I should probably state that the column "german" definitely does exist in the table "translate_content", and I have tried encapsulating the column names in back ticks. The problem only seems to arise when I use the COALESCE function, but I'm at a loss as to how it can work when I copy and paste it into the database, but not when I run it directly from PHP :/
Any help would be greatly appreciated, thanks.
as <column alias>to give the column a name that can then be referenced in PHP.