|
mysql> select * from tmp ;
+---------+-------+
| article | price |
+---------+-------+
| 0001 | 3.99 |
| 0002 | 10.99 |
| 0003 | 1.69 |
| 0004 | 19.95 |
+---------+-------+
mysql> select * from shop ;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | A | 3.45 |
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | B | 1.45 |
| 0003 | C | 1.69 |
| 0003 | D | 1.25 |
| 0004 | D | 19.95 |
+---------+--------+-------+
mysql> select article,dealer,price from shop,tmp where shop.article=tmp.article and shop.price=tmp.price ;
ERROR 1052: Column: 'article' in field list is ambiguous
why?
mysql> select shop.article,dealer,shop.price from shop,tmp where shop.article=tmp.article and shop.price=tmp.price ;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | C | 1.69 |
| 0004 | D | 19.95 |
+---------+--------+-------+
mysql> select tmp.article,dealer,shop.price from shop,tmp where shop.article=tmp.article and shop.price=tmp.price ;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | C | 1.69 |
| 0004 | D | 19.95 |
+---------+--------+-------+
按我自己的理解,article表不管select从哪个表中选择根据where都是唯一的结果
为什么还要我指定是哪个表的呢?
是不是两个表都有的字段,在select一定得告之select从那个中选吗? |
|