Sunday, April 17, 2005

Do a join on the same table in MySQL

You can join the same table in mysql!

mysql> select mv2.name, mv1.quantity
-> from dw.MAILVRS mv1, dw.MAILVRS mv2
-> where mv1.version_recnum = 124475 and mv1.package_recnum = mv2.dataflex_recnum_one;

+---------+----------+
| name | quantity |
+---------+----------+
| Kit A | 25000 |
| Control | 50000 |
| Kit E | 25000 |
+---------+----------+

1 comment:

Giulio said...

Also, for more detailed JOIN explanation, try http://buup.mephir.com/read/11/sql-join-close-up-what-when-and-how.html