我有一个有桌子的SQLite数据库:
table: import_info
Columns: First_Name, Last_Name, Payroll_ID, ... other columns not used
tabel employees
Columns: name, employee_num
我想从第一个表格中选择唯一名称和payroll_id,然后选择name
和employee_num
。
如果我在SQLite Manager中选择表并运行:
SELECT DISTINCT Last_Name || ' ' || First_Name AS name, Payroll_ID
AS employee_num
FROM import_info
我完美地得到了结果。但如果我尝试:
INSERT INTO employees (name, employee_num)
SELECT DISTINCT Last_Name || ' ' || First_Name AS name, Payroll_ID
AS employee_num
FROM import_info
我一无所获。没有错误,没有任何反应。
答案 0 :(得分:0)
您可以提供以下值:
INSERT INTO employees(name, employee_num, created_at, updated_at)
SELECT DISTINCT Last_Name || ' ' || First_Name AS name, Payroll_ID,
datetime('now'), datetime('now')
FROM import_info
但是,我很惊讶,遗漏这些值并不会导致错误。或许有些东西可以抑制错误。