I work on Firebird 2.5 and I have two tables, all their columns are similar except one has a primary key with auto increment and a not null foreign key field (A) for master table
I know I can use sql like this to insert all values from the two tables
insert into table1 select * from table2 where somthing = 'foo'
but what about the field (A) is there any way to insert this value manually in the same sql statement ? as this is the only field need to be entered manually
Thanks
You can specify both the source and target fields explicitly (and you should; don't use select *
unless you have a specific reason to):
insert into table1
(
col1,
col2,
col3,
col4
)
select
col1,
col2,
col3,
'foo'
from table2
where something = 'foo'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With