I have a SQLite DB that has a table:
table: import_info
Columns: First_Name, Last_Name, Payroll_ID, ... other columns not used
tabel employees
Columns: name, employee_num
I want to select the unique names and payroll_id's from the first table into the employees table as name
and employee_num
.
If I select the table in SQLite Manager and run:
SELECT DISTINCT Last_Name || ' ' || First_Name AS name, Payroll_ID
AS employee_num
FROM import_info
I get the results perfectly. But if I try:
INSERT INTO employees (name, employee_num)
SELECT DISTINCT Last_Name || ' ' || First_Name AS name, Payroll_ID
AS employee_num
FROM import_info
I get nothing. No error, nothing happens.
You can supply values as:
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
I'm surprised, however, that leaving out the values doesn't result in an error. Perhaps something is suppressing the errors.