mysql - How to SQL INSERT CROSS JOIN with other parameters -
i writing query insert data table. query must select id's 2 separate tables passed in parameter. able data 2 separate tables using cross join. however, i'm not sure how pass in string third parameter. here statement:
insert table1 (t2_id, t3_id) select t2_id, t3_id (select t2_id table2 table2.name = 'bob') t1 cross join(select t3_id table3 table3.data = 'blargh') t2; i id's need cross join need pass in 1 more parameter string value. how pass in well? thank in advance.
you can add string in select:
insert table1 (t2_id, t3_id, <col>) select t2_id, t3_id, 'a string' (select t2_id table2 table2.name = 'bob') t1 cross join(select t3_id table3 table3.data = 'blargh') t2; strictly speaking don't need sub-selects:
insert table1 (t2_id, t3_id, <col>) select t2_id, t3_id, 'a string' table2 t1 cross join table3 t2 t1.name = 'bob' , t2.data = 'blargh'
Comments
Post a Comment