I'm trying to insert data from table A to table B with query
INSERT INTO tableB(Status, UserIn, TableBID, Name)
SELECT
'Active',
UserInput,
COALESCE(MAX(TableAID),0)+1,
Name
FROM
tableA
But I get an error:
Invalid column name 'TableAID'.
Here my TableA:
CREATE TABLE TableA
(
Status VARCHAR(10),
UserInput VARCHAR(25),
TableAID INT,
Name VARCHAR(32)
)
And my tableB
CREATE TABLE TableB
(
Status VARCHAR(1),
UserIn VARCHAR(25),
TableBID INT,
Name VARCHAR(32)
)
TableBIDinTableB. Your DDL says you do though. You need to post the correct SQL and DDL because it is currently contradictory. You also need to post what you're actually trying to do at a higher level, i.e. load these rows into this table, generating a new id