简体   繁体   English

合并DBGrid列值

[英]Combine DBGrid column values

I have a DBGrid component of BDS 2006 in my application. 我的应用程序中有BDS 2006的DBGrid组件。 The snapshot of the grid is as follows. 网格的快照如下。

在此处输入图片说明

The DBGrid component is connected to a MySQL database, which gets populated at run time. DBGrid组件连接到MySQL数据库,该数据库在运行时填充。 The query I have used is: 我使用的查询是:

dm.MyQpayment.SQL.Clear;
dm.MyQpayment.SQL.Add('select sdate,stime,pcid,billno,c.customer_name,s.customerid,s.total,s.amount_paid,s.balance');
dm.MyQpayment.SQL.Add(',s.payment_type,s.payment_status,s.delivery from sales_order s left join customer_details c on s.customerid=c.customerid where s.payment_status=''complete'' and s.sdate>="'+startdate+'" and s.sdate<="'+enddate+'" ');
dm.MyQpayment.Active :=true;

I want to dispaly BILL NO and Machine id as BILL NO and the values should be 2_1, if Machine id is 2 and BILL NO is 1. Any idea how to do that? 我想将BILL NOMachine id分配为BILL NO并且如果Machine id为2而BILL NO为1,则值应为2_1。知道怎么做吗?

EDIT1 编辑1

select CAST(pcid AS CHAR) + "_" + CAST(billno AS CHAR) AS MachineAndBillNo
FROM tt.payment_details ;

this query gives me result as follows 这个查询给我结果如下

在此处输入图片说明

where it gives machineandbillno=billno+pcid 它给machineandbillno = billno + pcid的地方

I do not know the specific MySQL syntax requirements, but you have to concatenate those two fields together: 我不知道特定的MySQL语法要求,但您必须将这两个字段连接在一起:

SELECT 
  sdate, 
  stime, 
  CONCAT(CAST(pcid AS CHAR), '_', CAST(billno AS CHAR)) AS MachineAndBillNo,
  c.customer_name,
  ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM