MySQL Forums
Forum List  »  Newbie

Help with query (getting from two tables)
Posted by: Paul England
Date: June 29, 2005 08:37PM

I'm pulling values out of two tables. Definitions in one, examples in another one. Here's what the tables look like:

mysql> describe tango;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| japanese | varchar(50) | YES | | NULL | |
| furigana | varchar(50) | YES | | NULL | |
| meaning | varchar(255) | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+


mysql> describe examples
-> ;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| japanese | varchar(50) | YES | | NULL | |
| ex_jpn | text | YES | | NULL | |
| ex_eng | text | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+

Any given word can have between 0 and 3 examples. With my statement, if any example exists, I've got no problem. If there is no example, it returns an empty set. My SQL kung-fu isn't so hot. I'm display results in a webpage. I could use Perl to get around it, but that seems cheap. Here's the query I'm using:


select id,tango.japanese,furigana,meaning,ex_jpn,ex_eng FROM tango,examples WHERE id = 'x' AND tango.japanese = examples.japanese

Options: ReplyQuote


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


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.