火鸟根据情况插入



如何根据列条件将数据从一个表插入另一个表例如,一个表中有一列。如果其值为1,则插入数据库:火鸟2.5

基于您在评论中提供的示例:

INSERT INTO some_table (CARI_id, anydatacomefromcari ) 
SELECT EFATURA_KULLAN, someotherdata FROM CARI
WHERE EFATURA_KULLAN = 1

小提琴示例

结果:

用于测试的脚本是:

CREATE TABLE CARI (id INTEGER, EFATURA_KULLAN INTEGER, someotherdata INTEGER);
INSERT INTO CARI VALUES (1, 1, 55);
INSERT INTO CARI VALUES (2, 1, 44);
INSERT INTO CARI VALUES (3, 0, 99);
INSERT INTO CARI VALUES (4, 1, 12);
SELECT * FROM CARI;
CREATE TABLE some_table (CARI_id INTEGER, anydatacomefromcari INTEGER );
INSERT INTO some_table (CARI_id, anydatacomefromcari ) 
SELECT EFATURA_KULLAN, someotherdata FROM CARI
WHERE EFATURA_KULLAN = 1
SELECT * FROM some_table

结果:

+---------+-------------------------+
| CARI_id | anydatacomefromcari     |
+---------+-------------------------+
| 1       | 55                      |
+---------+-------------------------+
| 1       | 44                      |
+---------+-------------------------+
| 1       | 12                      |
+---------+-------------------------+

相关内容

  • 没有找到相关文章

最新更新