查询我有我的SQL数据库的两个表:问题写MySQL数据库
mysql> select *from crop;
+------+-----------+----------+
| no | name | type |
+------+-----------+----------+
| 1 | pineapple | fruits |
| 2 | wheat | mainFood |
| 1 | apple | fruits |
| 2 | corn | main |
| 3 | rose | flower |
| 2 | wheat | main |
| 2 | maize | main |
| 1 | drydates | fruits |
+------+-----------+----------+
mysql> select *from enviornment;
+---------+------------+----------+------+
| climate | irrigation | soil | no |
+---------+------------+----------+------+
| humid | medium | alluvial | 2 |
| humid | medium | black | 1 |
| humid | medium | red | 1 |
| sunny | low | black | 1 |
| sunny | medium | alluvial | 1 |
| wet | high | red | 2 |
| humid | low | red | 3 |
+---------+------------+----------+------+
我想从crop table
得到name
和type
领域,根据气候,土壤和灌溉。
我写我的查询以下列方式:
mysql> select T.name from((select name from crop)as T and (select no from envior
nment where climate like wet)as U)where T.no=U.no;
但是,当我试着执行它时,我得到以下错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and (select no from enviornment where climate like wet)as U)where T.no=U.no' at line 1
谁能告诉我如何重新写我的查询,以避免这个错误?
非常感谢快速答复... :) – user711934 2011-04-17 08:48:08