1

I have a DBGrid component of BDS 2006 in my application. The snapshot of the grid is as follows.

enter image description here

The DBGrid component is connected to a MySQL database, which gets populated at run time. 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?

EDIT1

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

this query gives me result as follows

enter image description here

where it gives machineandbillno=billno+pcid

  • It would be extremely helpful when asking questions about your data if you provided the data types of the columns. Nowhere above before your edit do you mention anything about one of the columns being `double`. What are the data types of the `pcid` and `billno` columns? – Ken White Mar 24 '12 at 13:39
  • pcid and billno datatype is INTEGER. –  Mar 26 '12 at 04:22

1 Answers1

1

I do not know the specific MySQL syntax requirements, but you have to concatenate those two fields together:

SELECT 
  sdate, 
  stime, 
  CONCAT(CAST(pcid AS CHAR), '_', CAST(billno AS CHAR)) AS MachineAndBillNo,
  c.customer_name,
  ...
NGLN
  • 43,011
  • 8
  • 105
  • 200