为mysql数据添加前缀 [英] adding prefix to mysql data
问题描述
我们正在开发发票管理应用程序,我们在 db 发票编号中添加了 2 列.和客户 ID,那么我们如何给出唯一的编号.要像 2011/1 这样的发票和客户 ID,我们如何放置 Cust-1 ?甚至有没有可能开始发票号.在每个新财政年度开始时再次从 1(如 2012/1)?
We are working on invoice management app, and we have added 2 columns to db Invoice no. and Customer id, so how can we give an unique no. to invoice like 2011/1 and for customer id how can we put Cust-1 ? even is there any possibility to start invoice no. from 1 again(like 2012/1) at beginning of each new financial year?
推荐答案
将列结构设置成这样...
Set the column structure as such...
- invoice_id == 自动递增
- invoice_year == YEAR(NOW())
- invoice_customer_id == customer_id 来自客户表
- 等等...
...然后在视图中向最终用户显示一个串联的 id (2011-1-1234).
...and then display to the end users a concatenated id (2011-1-1234) in the view.
看来您确实需要根据输出来组织架构.
It really seems like you need to organize the schema based on your output.
这篇关于为mysql数据添加前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!