I need help regarding insert multiple data from 2 table to one table. the data will be from another table. I have tables below.
table a
id word status
12 test ok
13 test2 ook
14 test3 ok
table b
id synonyms status
30 abc ok
31 abcd ok
32 ccc ok
35 ddd ok
36 eeee ok
table results
id searchwordid searchsynonimid status
1 12 30 ok
2 12 34 ok
3 12 33 ok
I need insert table results from table a
and table b
. on data/id in table a have some data in table b
. my problem is when insert data, how to automatically add searchwordid
field when have multiple data. I do SELECT UNION ALL query
. the value will be get from dynamic field, dynamic field is for table b, but for table a just have one field.
all query must be run onetime when press submit button. really need helps.
This could be your friend:
INSERT INTO table_c SELECT * FROM table_a,table_b;
For further information take a look at w3schools
Maybe the clause row_number() could help you, using like this:
select row_number() over(order by a.id), a.id, b.id, b.status
from tablea a, tableb b
where b.synonyms = 'somethig'
and a.word = 'else'
group by a.id, b.id, b.status
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.