SQL ÅжÏÉí·ÝÖ¤ºÅÂë
ÏÖÒªÇó²éѯ½çÃ棺²»ÂÛ15λ»òÕß18λÉí·ÝÖ¤ºÅ¶¼Äܲéѯ³öÊý¾Ý¿âÖÐËùÓе±Ç°Óû§ÐÅÏ¢¡£
·½°¸1£º
create or replace function CONVERT_ID_15 (/*ת»»Éí·ÝÖ¤ºÅΪ15λ*/
p_id2 in varchar2
) return varchar2
is
p_id varchar2(20);
id varchar2(15);
begin
p_id:=ltrim(p_id2);
p_id:=rtrim(p_id);
if length(p_id) = 18 then
id:=substr(p_id, 1, 6) || substr(p_id, 9, 9);
else
id:=substr(p_id, 1, 15);
end if;
return id;
exception
when others then
return null;
end
;
//delphi
s:=s + ' and CONVERT_ID_15(hf_id) = ''' + ConvertID15(edHf_id.Text) + '''';
·½°¸2£º
ÔÚ´úÂë¶Ë °ÑÊäÈëµÄÉí·ÝÖ¤ºÅͳһ½Ø³É15λ£¬È»ºó¸ñʽ»¯³É'430221£¥850924382£¥'
//15λÉí·ÝÖ¤ÀàËƳÉ18λ ×¢ÒâÒªÏÈת³É15λ
function hf_id18(id15:String):String;
var
id18:String;
begin
if length(id15) = 15 then
begin
id18:=copy(id15,0,6)+'%'+copy(id15,7,9)+'%';
end
else
begin
id18:= id15;
end;
result:=id18;
end;
SQL:=SQL+' AND YQ_IDCARD like ''' + CardIdNew+'''';
²éѯËÙ¶ÈÉõÖÁ±È·½°¸Ò»»¹ÉÔ¿ì¡£
Ïà¹ØÎĵµ£º
Ö´ÐÐ˳Ðò:´Ó×óµ½ÓÒ,±äÁ¿ÓÅÏÈ,ÖðÐиüÐÂ
Õª×ÔCSDNµÄÀý×Ó(http://topic.csdn.net/u/20091030/16/7fd75fa6-bdb9-4516-9b27-48aef69703ba.html
http://topic.csdn.net/u/20090904/16/e5dad9c7-fb59-41b9-b28d-e3b71c3e8420.html)
1.±äÁ¿ÓÅÏÈ
create table #t (field1 varchar(10),field2 varchar(10))
insert #t sel ......
ÉÏÃæÎÒÃÇÌáµ½µÄÊÇһЩ»ù±¾µÄÌá¸ß²éѯËٶȵÄ×¢ÒâÊÂÏî,µ«ÊÇÔÚ¸ü¶àµÄÇé¿öÏÂ,ÍùÍùÐèÒª·´¸´ÊÔÑé±È½Ï²»Í¬µÄÓï¾äÒԵõ½×î¼Ñ·½°¸¡£×îºÃµÄ·½·¨µ±È»ÊDzâÊÔ£¬¿´ÊµÏÖÏàͬ¹¦ÄܵÄSQLÓï¾äÄĸöÖ´ÐÐʱ¼ä×îÉÙ£¬µ«ÊÇÊý¾Ý¿âÖÐÈç¹ûÊý¾ÝÁ¿ºÜÉÙ£¬ÊDZȽϲ»³öÀ´µÄ£¬Õâʱ¿ÉÒÔÓò鿴ִÐмƻ®£¬¼´£º°ÑʵÏÖÏàͬ¹¦ÄܵĶàÌõSQLÓï¾ä¿¼µ½²éѯ·ÖÎöÆ÷£¬°´ ......
×ܽáÒ»ÏÂSQLÓï¾äÖÐÒýºÅ(')¡¢quotedstr()¡¢('')¡¢format()ÔÚSQLÓï¾äÖеÄÓ÷¨ÒÔ¼°SQLÓï¾äÖÐÈÕÆÚ¸ñʽµÄ±íʾ(#)¡¢('')
ÔÚDelphiÖнøÐÐ×Ö·û±äÁ¿Á¬½ÓÏà¼Óʱµ¥ÒýºÅÓÃ('''),ÓÖÒýºÅÓÃ('''')±íʾ
Ê×Ïȶ¨Òå±äÁ¿
var
AnInt:integer=123;//ΪÁË·½±ãÔڴ˶¼¸øËüÃǸ³³õÖµ¡£ËäÈ»¿ÉÄÜÔÚÒý¸³³õÖµÔÚijЩÇé¿öϲ»¶Ô
AnIntStr:string='456'; ......
ʲôÊÇÊý¾Ý¿â·ÖÇø£¿
Êý¾Ý¿â·ÖÇøÊÇÒ»ÖÖ¶Ô±íµÄºáÏò·Ö¸î£¬Sql server 2005ÆóÒµ°æºÍÖ®ºóµÄSql server°æ±¾²ÅÌṩÕâÖÖ¼¼Êõ£¬ÕâÖÖ¶Ô±íµÄºáÏò·Ö¸î²»Í¬ÓÚ2000Öеıí·Ö¸î£¬Ëü¶Ô·ÃÎÊÓû§ÊÇ͸Ã÷µÄ£¬Óû§²¢²»»á¸Ð¾õµÄ±í±»ºáÏò·Ö¸îÁË¡££¨2000ÖеıíºáÏò·Ö¸îÊǽ¨n¸ö±íÀýÈ簴ʱ¼ä½¨±íÿÔÂÒ»¸ö±í£¬±íÃû²»Í¬£¬×îºóÐèÒª×öÒ»¸ö´óÊÓͼ£©
¹ØÓÚ¾ß ......
ORACLE SQLÓï¾äÓÅ»¯×ܽá
1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, Ä ......