'class'と 'class1'の2つのテーブルがあります。
クラス:
+------+---------+---------+
| name | classid | rollnum |
+------+---------+---------+
| ram | 10 | 1 |
| ram | 10 | 2 |
| ram | 20 | 1 |
| ram | 20 | 2 |
| ram | 20 | 3 |
+------+---------+---------+
次に、以下のクエリを実行します。
insert into class1 (name1,classid1,rollnum1) values((select name from class where name='ram' and classid='10'),(select classid from class where name='ram' and classid='10'),(select rollnum from class where name='ram' and classid='10'));
そのため、「class1」テーブルは次のようになります。
+-------+----------+----------+------+
| name1 | classid1 | rollnum1 | add1 |
+-------+----------+----------+------+
| ram | 10 | 1 | NULL |
| ram | 10 | 2 | NULL |
+-------+----------+----------+------+
しかし、上記のクエリは私に以下のエラーを与えます:
ERROR 1242 (21000): Subquery returns more than 1 row
VALUES
1つのSELECT
ステートメントを使用する代わりに:
insert into class1 (name1,classid1,rollnum1)
select name,classid,rollnum
from class
where name='ram' and classid='10'
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加