Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

×ܽáÒ»ÏÂdelphiÖÐSQLÓï¾äÖÐÒýºÅ

×ܽáÒ»ÏÂSQLÓï¾äÖÐÒýºÅ(')¡¢quotedstr()¡¢('')¡¢format()ÔÚSQLÓï¾äÖеÄÓ÷¨ÒÔ¼°SQLÓï¾äÖÐÈÕÆÚ¸ñʽµÄ±íʾ(#)¡¢('')
ÔÚDelphiÖнøÐÐ×Ö·û±äÁ¿Á¬½ÓÏà¼Óʱµ¥ÒýºÅÓÃ('''),ÓÖÒýºÅÓÃ('''')±íʾ
Ê×Ïȶ¨Òå±äÁ¿
var
AnInt:integer=123;//ΪÁË·½±ãÔڴ˶¼¸øËüÃǸ³³õÖµ¡£ËäÈ»¿ÉÄÜÔÚÒý¸³³õÖµÔÚijЩÇé¿öϲ»¶Ô
AnIntStr:string='456';
AStr:string='abc';
AFieldName: string='×Ö·ûÐͱàºÅ';
ATableName: string='YourTable';
ADate:Tdatetime=now;
Adoquery1:tadoquery;
1£¬DelphiÓï¾ä
adoquery1.sql.text:=
'select ×Ö·ûÐͱàºÅ from YourTable where ×Ö·ûÐͱàºÅ='abc' and ÕûÐͱàºÅ=123';
µÈ¼ÛÓÚ
adoquery1.sql.text:=
'select '+AFieldName+' from '+ATableName+' where '+AFieldName
+'='''+AStr+''' and ÕûÐͱàºÅ='+AnIntStr;
Ò²µÈ¼ÛÓÚ
adoquery1.sql.text:=
'select '+AFieldName+' from '+ATableName+' where '+AFieldName
+'='+QuotedStr(AStr)+' and ÕûÐͱàºÅ='+Inttostr(AnInt);
´«µ½Êý¾Ý¿â·þÎñÆ÷Ϊ£º
select ×Ö·ûÐͱàºÅ from YourTable where ×Ö·ûÐͱàºÅ='abc' and ÕûÐͱàºÅ=123
2,DelphiÓï¾äÖÐÈÕÆÚ±íʾ
¶ÔÓÚaccessÊý¾Ý¿â£º
adoquery1.sql.text:=
'select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î=#2003-12-01#';
µÈ¼ÛÓÚ£º
adoquery1.sql.text:=
'select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î=#'+FormatDateTime('yyyy-MM-dd',now)+'#';
´«µ½·þÎñÆ÷Ϊ£º
select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î=#2003-12-01#
¶ÔÓÚMSSQLÊý¾Ý¿â£º
adoquery1.sql.text:=
'select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î='2003-12-01'';
µÈ¼ÛÓÚ£º
adoquery1.sql.text:=
'select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î='''+FormatDateTime('yyyy-MM-dd',now)+'''';
Ò²µÈ¼ÛÓÚ£º
µÈ¼ÛÓÚ£º
adoquery1.sql.text:=
'select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î='+QuotedStr(FormatDateTime('yyyy-MM-dd',now));
´«µ½·þÎñÆ÷Ϊ£º
select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î='2003-12-01'
ÈÕÆÚ×ֶλ¹¿ÉÒÔÕâÑù±íʾ
DelphiÓï¾ä
adoquery1.sql.text:=
'select ×Ö·ûÐͱàºÅ from YourTable where ÈÕÆÚÐÍ×Ö¶Î>='+QuotedStr(FormatDateTime('yyyy-MM-dd',now))
+' and ÈÕÆÚÐÍ×Ö¶Î<='+QuotedStr(FormatDateTime('yyyy-MM-dd',now+1));//Ã÷Ìì
µÈ¼ÛÓÚ
adoquery1.sql.text:=
'sele


Ïà¹ØÎĵµ£º

SQLÓï¾äЧÂÊÎÊÌâµÄ¼¸µã×ܽá

 1. SQLÓÅ»¯µÄÔ­ÔòÊÇ£º
  ½«Ò»´Î²Ù×÷ÐèÒª¶ÁÈ¡µÄBLOCKÊý¼õµ½×îµÍ,¼´ÔÚ×î¶ÌµÄʱ¼ä´ïµ½×î´óµÄÊý¾ÝÍÌÍÂÁ¿¡£  
  µ÷Õû²»Á¼SQLͨ³£¿ÉÒÔ´ÓÒÔϼ¸µãÇÐÈ룺  
  ¼ì²é²»Á¼µÄSQL£¬¿¼ÂÇÆäд·¨ÊÇ·ñ»¹ÓпÉÓÅ»¯ÄÚÈÝ  
  ¼ì²é×Ó²éѯ   ¿¼ÂÇSQL×Ó²éѯÊÇ·ñ¿ÉÒÔÓüòµ ......

Oracle³£ÓÃSQLÓï¾ä(PL/SQL developer¹¤¾ßϵÄ)

 ½¨±í
create table users(
id number(4) primary key,
username varchar2(10),
password varchar2(10)
)
²éѯ±í²¢½âËø±í(¼´¿ÉÒÔµã»÷ÊäÈë¿òÏÂÃæµÄ"Ëø"ͼ±ê¹¤¾ß, ¼´"Edit data")
select * from users for update
ɾ³ý±íÖжàÓàµÄÁÐ
alter table mobilephone drop column mobiletype
תÔØ
------------------- ......

SQL UpdateÓï¾äµÄÖ´ÐÐ˳Ðò

Ö´ÐÐ˳Ðò:´Ó×óµ½ÓÒ,±äÁ¿ÓÅÏÈ,ÖðÐиüÐÂ
 Õª×Ô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 ......

ORACLE PL/SQL ¼¯ºÏѧϰ±Ê¼Ç(¶þ)

Èý¡¢Ç¶Ì×±íµÄʹÓ÷½·¨
 
1¡¢½«Ç¶Ì×±í¶¨ÒåΪPL/SQLµÄ³ÌÐò¹¹Ôì¿é
 
TYPE type_name IS TABLE OF element_type[NOT NULL];
 
ÈçÏÂÀýËùʾ£º
DECLARE

-- Define a nested table of variable length strings.
TYPE card_table IS TABLE OF VARCHAR2(5 CHAR);

-- Declare and initialize a n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ