sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+quotedstr(copy((node.Text),1,2)) and tgp_cust.cust_no=tcustomer.cust_no);
不知是错在那里,就是到最后的tgp_cust.cust_no时就通不过了,是不是要满足双重条件的连接词,and用错了。急,在线急盼高人指点。
不知是错在那里,就是到最后的tgp_cust.cust_no时就通不过了,是不是要满足双重条件的连接词,and用错了。急,在线急盼高人指点。
sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='''+quotedstr(copy((node.Text),1,2))+''' and tgp_cust.cust_no='''+tcustomer.cust_no+'''');
应该是这样的吧 +' and tgp_cust.cust_no=tcustomer.cust_no'
tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+''''+quotedstr(copy((node.Text),1,2))+''''+and tgp_cust.cust_no=tcustomer.cust_no');
这样应该是对的了
sql.text :=
'select t1.cust_no,t1.cust_name,t1.cust_bp,t1.bp_code,t1.bp_type,t1.reg_date,t1.unreg_date,t1.mobile,t1.email from tgp_cust as t2,tcustomer as t1 where t2.group_no='''+quotedstr(copy((node.Text),1,2))+''' and t2.cust_no=t1.cust_no';另外,建议 多使用tgp_cust as t2,tcustomer as t1
使用t1,t2之后,可以让代码变得更加简洁。
1。可以直接copy中间的内容直接使用。
2。''' 是,3个半角单引号