Mysql插入选择值

时间:2014-12-30 07:12:05

标签: mysql sql database jtable

我在JTables的程序中有这个查询:

prs = con.prepareStatement("INSERT INTO reportTable (main_id,cat,pro,price,qty,total)"+
                                        " SELECT main_id,catId,proId,priceId"+
                                        " FROM mainTable"+
                                        " WHERE main_id= " + table.getValueAt(i,0));

" qty"的值和"总计"将来自Jtable。 我怎样才能将qty和total作为查询?

1 个答案:

答案 0 :(得分:0)

将select语句用作 - >从maintainble.proid = jtable.proid(或两个表之间的任何其他映射id)中的maintainble join jtable中选择main_id,catid,proid,priceid,qty,total,其中main_id = table.getValueAt(i,0));