MySQL Forums
Forum List  »  Newbie

Re: Help with query (getting from two tables)
Posted by: Jay Pipes
Date: June 29, 2005 08:51PM

I gather you want to return all definitions, even if they have no examples? If this is the case, you can use a LEFT JOIN with an IFNULL() function to "fill in the blanks":

SELECT
t.id
, t.japanese
, t.furigana
, t.meaning
, IFNULL(e.ex_jpn, 'No example') as 'ex_jpn'
, IFNULL(e.ex_eng, 'No example') as 'ex_eng'
FROM tango t
LEFT JOIN examples e
ON t.japanese = e.japanese
WHERE t.id = 'x';

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
Re: Help with query (getting from two tables)
June 29, 2005 08:51PM


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.