mysql - How to insert multiple rows at once using INSERT INTO query -


the base table

so here problem, want insert data table (webform_submitted_data) anather table (feedback_analysis) data want copy 1 nid=20 , cid= 3,4,5 table this,

the feedback_analysis table

so here doing,

 insert feedback_analysis (service,type,feedback)          values ((select data webform_submitted_data nid=20 , cid=5),(select data webform_submitted_data nid=20 , cid=3),(select data webform_submitted_data nid=20 , cid=4)); 

but i'm getting error error 1242 (21000): subquery returns more 1 row

i got reason behind that, subquery returning 2 rows in result single insert into query can not handle.

i want insert all rows in table, can process further

so please me find solution this.

i want apply trigger directly insert values feedback_analysis table once new value of nid=20 inserted table of weform_submitted_data

thank you.

you can use limit 1

insert feedback_analysis (service,type,feedback)          values ((select data                  webform_submitted_data                  nid=20 , cid=5                  limit 1),                 (select data                  webform_submitted_data                  nid=20 , cid=3                  limit 1),                 (select data                  webform_submitted_data                  nid=20 , cid=4                  limit 1)); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

methods - python can't use function in submodule -

c# - ErrorThe type or namespace name 'AxWMPLib' could not be found (are you missing a using directive or an assembly reference?) -