テーブル(item1)にテーブル(item2)の値を挿入し、そのitem2テーブルにない日付を挿入したいとします。select文を使用してSQL文を挿入する
これを達成するためにselect文を使用してSQL挿入を文に書き込むにはどうすればよいですか?
例:
INSERT into item1(date, name, qty)
values(datevalue, select col1, col2 from item2);
これが機能していません。それを修正するために私は何をすべきですか?
insert into daily_stock(date, product_id, name, weight, qty, free_issues, sales_price,
purchased_price, category, last_purchased_date)
select
**'"+today+"'**,
productId, name, weight, newQty, freeIssues, NewSalesPrice,
NewPurchasePrice, category, datePurchased
from product
私はjavaを使用していますが、今日は文字列変数ですが、データは挿入されていません、何が間違っていますか?
http://stackoverflow.com/questions/224732/sql-update-from-one-table-to-another-based-on-a-id-match –