I have the issue while inserting data from product table which contains 3 rows with quote_id =1 I am only able to get first one from product to price table.
Code to insert in price
db.execsql("insert into price (name, quantity ) values ((select from product title, quantity where quote_id =1 ) ) " )
Updated :
i want to insert a static id of one in same statment; value = 1;
insert into price (price_id,name, quantity,row_total)
"+value+",select title, quantity,SUM(price*quantity)
from product where quote_id = 1
Something this i want to acheive this
You are not using the correct syntax. Try this:
insert into price (price_id, name, quantity)
select 1, title, quantity
from product
where quote_id = 1
You must not use the keyword values
in this case.
This will return all rows where quote_id = 1
from product
table and insert them into price
table.
If there is only 1 row returned then this 1 row will be inserted.
Are there any other constraints in price
table that do not allow the insertion of more rows, like unique indexes?
Edit:
db.execsql(
"insert into price (price_id, name, quantity) select " +
value +
", title, quantity from product where quote_id = 1");