DELPHI SQL语句中使用IN 的变量如何写
SQL语句为select*frompower.check_snwhereserial_numberin(SN);其中SN为变量,为读取的memo1.text的值,我的设想...
SQL语句为select * from power.check_sn where serial_number in (SN);其中SN为变量,为读取的memo1.text的值,我的设想是先将txt文件内容读取到memo1中,然后使用上面的语句进行查询,要怎么写
ADOQUERY1.SQL.Text:='select SN,t1.serial_number SMT_SN,pdline_name MI_LINE,out_process_time MI_TIME,SMT_LINE,SMT_TIME from '
+'sajet.g_sn_travel t1 join sajet.sys_pdline t2 on t1.pdline_id=t2.pdline_id join(select t3.serial_number SN,t1.serial_number SMT_SN,pdline_name SMT_LINE,out_process_time SMT_TIME from sajet.g_sn_travel t1,sajet.sys_pdline t2,sajet.g_sn_keyparts t3 '
+'where t1.serial_number=t3.item_part_sn and t1.pdline_id=t2.pdline_id and length( item_part_sn) =12 and t1.process_id=''100008'' and t3.serial_number IN ('+memo1.Text+')) t4 on t1.serial_number=t4.SMT_SN where t1.process_id=''100037'';' 展开
ADOQUERY1.SQL.Text:='select SN,t1.serial_number SMT_SN,pdline_name MI_LINE,out_process_time MI_TIME,SMT_LINE,SMT_TIME from '
+'sajet.g_sn_travel t1 join sajet.sys_pdline t2 on t1.pdline_id=t2.pdline_id join(select t3.serial_number SN,t1.serial_number SMT_SN,pdline_name SMT_LINE,out_process_time SMT_TIME from sajet.g_sn_travel t1,sajet.sys_pdline t2,sajet.g_sn_keyparts t3 '
+'where t1.serial_number=t3.item_part_sn and t1.pdline_id=t2.pdline_id and length( item_part_sn) =12 and t1.process_id=''100008'' and t3.serial_number IN ('+memo1.Text+')) t4 on t1.serial_number=t4.SMT_SN where t1.process_id=''100037'';' 展开
3个回答
2012-07-05 · 知道合伙人软件行家
关注
展开全部
memo1.lines.loadformfile(filepath);
adoquery1.close;
adoquery1.sql.text := ‘扮雀
select * from power.check_sn where serial_number in (’ + memo1.text +‘)’;
adoquery1.open;
这里有一个问题,当serial_number是字符串镇碧时,需要分词厅旅早并加上‘’号
adoquery1.close;
adoquery1.sql.text := ‘扮雀
select * from power.check_sn where serial_number in (’ + memo1.text +‘)’;
adoquery1.open;
这里有一个问题,当serial_number是字符串镇碧时,需要分词厅旅早并加上‘’号
展开全部
关键看你的txt文件内容格式 ,serial_number 类型
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ASql : String;
ASql :='select * from power.check_sn where serial_number in ('枣态清+memo1.text+')';
adoquery1.sql.text:=ASql;
adoquery1.open;
注意:memo1.text的值,需要凳前用‘,’隔开。闭灶
ASql :='select * from power.check_sn where serial_number in ('枣态清+memo1.text+')';
adoquery1.sql.text:=ASql;
adoquery1.open;
注意:memo1.text的值,需要凳前用‘,’隔开。闭灶
追问
'2B2277TYW9PLG','2B2277TFW9PLG','2B2277TDW9PLG'
格式是这样的,在Toad中查询正常,程序中报字符无效,不知道是什么原因
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询