如何连接三列并插入另一个表 [英] how to concatenate three columns and insert the another table

查看:78
本文介绍了如何连接三列并插入另一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表名:购买



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 +


这篇关于如何连接三列并插入另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆