MySQL Forums
Forum List  »  Newbie

Help - Duplicate yet diferent data in sql query
Posted by: Fraiser Bristol
Date: May 31, 2007 11:47AM

Is there a single SQL Query that will do the following?

mysql> SELECT * FROM user;
+----+----------+
| id | username |
+----+----------+
|  1 | Bill     |
|  2 | Bob      |
|  3 | Hank     |
|  4 | Jim      |
+----+----------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM email;
+----+-------+------+---------------------------------------+
| id | _from | _to  | message                               |
+----+-------+------+---------------------------------------+
|  1 |     1 |    2 | Blah, blah, blah                      |
|  2 |     1 |    3 | I told Bob to Blah, Blah, Blah        |
|  3 |     3 |    4 | Bill told Bob to Blah, Blah, Blah     |
|  4 |     4 |    2 | Did Bill tell you to Blah, Blah, Blah |
+----+-------+------+---------------------------------------+
4 rows in set (0.00 sec)
What SQL Query would result in the following...???
mysql> SELECT ??????????????????????????????;
+----+-------+------+---------------------------------------+
| id | _from | _to  | message                               |
+----+-------+------+---------------------------------------+
|  1 |  Bill |  Bob | Blah, blah, blah                      |
|  2 |  Bill | Hank | I told Bob to Blah, Blah, Blah        |
|  3 |  Hank |  Jim | Bill told Bob to Blah, Blah, Blah     |
|  4 |   Jim |  Bob | Did Bill tell you to Blah, Blah, Blah |
+----+-------+------+---------------------------------------+
4 rows in set (0.00 sec)

Options: ReplyQuote


Subject
Written By
Posted
Help - Duplicate yet diferent data in sql query
May 31, 2007 11:47AM


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.