INSERT INTO table1 VALUES ("string", 10, [int]).
I have the value of ''string" and the 10, but i've to find that [int] from a select like this:
SELECT idTable2
FROM table2
WHERE ...
Solutions:Use an
insert ... select
query, and put the known values in the select
:insert into table1
select 'A string', 5, idTable2
from table2
where ...
Issue that may come out:A problem I've found with this approach is that if the
SELECT
returns zero records then the statement succeeds but no data is INSERT
. – Neil C. Obremski Feb 13 '14 at 1:52
No comments:
Post a Comment