This is probably a duplicate of another question but I can't understand how to fix this error even following the directions of the answers.
I've got two table, and the second one should contain part of the columns of the first one.
These are their schemas (consider that I left out some columns that I don't need) :
First Table
ID | num | acquisto | dataacquisto | descrizione | modello | ubicazione
Second Table
ID | tipo | data | id_bene | descrizione | modello | ubicazione | importo
I semplified the first schema since I'm just looking for the method to move the datas from the first table to the second one.
The problem is that I can't set the tipo
field using a SELECT
query, but its value should be chosed every time I run the query.
I tried with this SQL, but it's returning me this error :
INSERT INTO riepilogo (tipo, data, id_bene, descrizione, modello, ubicazione, importo) VALUES ('CARICO', (SELECT dataacquisto, id, descrizione, modello, ubicazione, acquisto FROM beni));
Operand should contain 1 column(s)
I tried with other queries following the tips of other question, but there's no solution working for me.
Thanks a lot and sorry for my english!
Include the constant in the select query itself.
Try this:
insert into riepilogo (
tipo,
data,
id_bene,
descrizione,
modello,
ubicazione,
importo
)
select 'CARICO',
dataacquisto,
id,
descrizione,
modello,
ubicazione,
acquisto
from beni