MySQL Forums
Forum List  »  Newbie

SET something to NULL if value not matched.
Posted by: Paul Smith
Date: August 03, 2005 08:29PM

I posted this in another MySQL forum yesterday. It's been 24 hours, and am getting no help, so will post here.

I've got two tables. An info table and a description table. The two tables share an ID column. The info table has no null values. The description table will have at least one description to correspond to an item in the info table... sometimes more. If there's only one description, it will be in English. If it has more, there's a chance it's in Japanese (denoted as 'e' or 'j' by a column).

My query is fine and dandy for English, but it doesn't work for Japanese. As before, there isn't always a Japanese description. If there's not, my last conditional (WHERE dsc.language ="j") will always fail (as you shall see). Here's the query when want to display a Japanese description:

SELECT title,developer,publisher,
IFNULL(dsc.description, ' ') as description
FROM info
LEFT JOIN dsc ON info.id = dsc.id
WHERE dsc.language = "j"
AND info.id = "100"

I'm using PHP as the interface. I'm sure I could find a way around using an extra command, but would rather do it in one query if possible.

Thanks. I'm on MySQL 3.23.

Options: ReplyQuote


Subject
Written By
Posted
SET something to NULL if value not matched.
August 03, 2005 08:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.