如何连接三列并插入另一个表

问题描述:

表名:购买



or_name ord_yr ord_numer



sal 2011 0004







插入表后价值为



表名:purchase_order



订单



sal-2011-0004







再次增加ord_number将0004替换为005并更新购买表,

table name : purchase

or_name ord_yr ord_numer

sal 2011 0004



after insert the table the value is

table name: purchase_order

order

sal-2011-0004



and again increment the ord_number replace 0004 to 005 and update the purchase table ,

在数据库中创建列ord_counter。然后获取每个ord_year的计数器的最后一个值。

增加计数器的最后一个值。
Create a column ord_counter in your database. Then get the last value of the counter per ord_year.
Increment the last value of the counter.


如果你使用SQL那么......



if you are using SQL then....

INSERT INTO purchase_order
(order)
SELECT or_name+'-'+ ord_yr+'-'+  ord_numer as order
FROM purchase;





将purchase_order id设置为自动增量




oracle使用
||

insted of +



set purchase_order id as auto increment


in oracle use ||
insted of +