我想从一个表中读取所有数据,然后将一些数据插入到另一个表中。我的查询是
INSERT INTO mt_magazine_subscription ( magazine_subscription_id, subscription_name, magazine_id, status ) VALUES ( (SELECT magazine_subscription_id, subscription_name, magazine_id FROM tbl_magazine_subscription ORDER BY magazine_subscription_id ASC), '1')
但我有一个错误
#1136 - Column count doesn't match value count at row 1
请帮我。
您可以使用INSERT … SELECT语法。请注意,您可以在SELECT部分中直接引用“ 1”。
INSERT INTO mt_magazine_subscription ( magazine_subscription_id, subscription_name, magazine_id, status ) SELECT magazine_subscription_id, subscription_name, magazine_id, '1' FROM tbl_magazine_subscription ORDER BY magazine_subscription_id ASC