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

SQLÓÅ»¯½éÉÜÒ»

Ò»¡¢Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)
 
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû,Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí. ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í.µ±ORACLE´¦Àí¶à¸ö±íʱ, »áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á¬½ÓËüÃÇ.Ê×ÏÈ,ɨÃèµÚÒ»¸ö±í(from×Ó¾äÖÐ×îºóµÄÄǸö±í)²¢¶Ô¼Ç¼½øÐÐÅÉÐò,È»ºóɨÃèµÚ¶þ¸ö±í(from×Ó¾äÖÐ×îºóµÚ¶þ¸ö±í),×îºó½«ËùÓдӵڶþ¸ö±íÖмìË÷³öµÄ¼Ç¼ÓëµÚÒ»¸ö±íÖкÏÊʼǼ½øÐкϲ¢.
 
 
ÀýÈç:
 
±í TAB1 16,384 Ìõ¼Ç¼
 
±í TAB2 1 Ìõ¼Ç¼
 
Ñ¡ÔñTAB2×÷Ϊ»ù´¡±í (×îºÃµÄ·½·¨)
 
select count(*) from tab1,tab2 Ö´ÐÐʱ¼ä0.96Ãë
 
Ñ¡ÔñTAB1×÷Ϊ»ù´¡±í (²»¼ÑµÄ·½·¨)
 
select count(*) from tab2,tab1 Ö´ÐÐʱ¼ä26.09Ãë
 
 
Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄǾÍÐèҪѡÔñ½»²æ±í(intersection table)×÷Ϊ»ù´¡±í, ½»²æ±íÊÇÖ¸ÄǸö±»ÆäËû±íËùÒýÓõıí.
 
 
ÀýÈç:
 
EMP±íÃèÊöÁËLOCATION±íºÍCATEGORY±íµÄ½»¼¯.
 
SELECT * from LOCATION L , CATEGORY C, EMP E
WHERE E.CAT_NO = C.CAT_NO AND E.LOCN = L.LOCN
AND E.EMP_NO BETWEEN 1000 AND 2000
 
½«±ÈÏÂÁÐSQL¸üÓÐЧÂÊ
 
SELECT E.CAT_NO from EMP E, LOCATION L , CATEGORY C
WHERE E.EMP_NO BETWEEN 1000 AND 2000
AND E.CAT_NO = C.CAT_NO AND E.LOCN = L.LOCN
¶þ¡¢WHERE×Ó¾äÖеÄÁ¬½Ó˳Ðò
 
ORACLE²ÉÓÃ×Ô϶øÉϵÄ˳Ðò½âÎöWHERE×Ó¾ä,¸ù¾ÝÕâ¸öÔ­Àí,±íÖ®¼äµÄÁ¬½Ó±ØÐëдÔÚÆäËûWHEREÌõ¼þ֮ǰ, ÄÇЩ¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐëдÔÚWHERE×Ó¾äµÄĩβ.
 
ÀýÈç:
 
(µÍЧ,Ö´ÐÐʱ¼ä156.3Ãë)
 
SELECT … from EMP E WHERE SAL > 50000 AND JOB = ‘MANAGER'
AND 25 < (SELECT COUNT(*) from EMP
WHERE MGR=E.EMPNO);
 
(¸ßЧ,Ö´ÐÐʱ¼ä10.6Ãë)
 
SELECT … from EMP E
WHERE 25 < (SELECT COUNT(*) from EMP WHERE MGR=E.EMPNO)
AND SAL > 50000
AND JOB = ‘MANAGER';
 
Èý¡¢SELECT×Ó¾äÖбÜÃâʹÓà ‘ * ‘
 
µ±ÄãÏëÔÚSELECT×Ó¾äÖÐÁгöËùÓеÄCOLUMNʱ,ʹÓö¯Ì¬SQLÁÐÒýÓà ‘*' ÊÇÒ»¸ö·½±ãµÄ·½·¨.²»ÐÒµÄÊÇ,ÕâÊÇÒ»¸ö·Ç³£µÍЧµÄ·½·¨. ʵ¼ÊÉ


Ïà¹ØÎĵµ£º

mysqlµ¼ÈësqlÎļþ:Mysqlµ¼Èëµ¼³ö.sqlÎļþ

mysqlµ¼ÈësqlÎļþ:Mysqlµ¼Èëµ¼³ö.sqlÎļþ
²½ÖèÈçÏ£º
Ò».MYSQLµÄÃüÁîÐÐģʽµÄÉèÖãº
×ÀÃæ->ÎҵĵçÄÔ->ÊôÐÔ->»·¾³±äÁ¿->н¨->
PATH=“£»path\mysql\bin;”ÆäÖÐpathΪMYSQLµÄ°²×°Â·¾¶¡£
¶þ.¼òµ¥µÄ½éÉÜÒ»ÏÂÃüÁîÐнøÈëMYSQLµÄ·½·¨£º
1.C:\>mysql -h hostname -u username -p
°´ENTER ......

SQLÓï¾ä¾­µäʵÀý

ÎÞÂÛÄúÊÇһλ SQL µÄÐÂÊÖ£¬»òÊÇһλֻÊÇÐèÒª¶Ô SQL ¸´Ï°Ò»ÏµÄ×ÊÁϲִ¢Òµ½çÀϽ«£¬Äú¾ÍÀ´¶ÔµØ·½ÁË£¡
- SQL Ö¸Áî: SQL ÈçºÎ±»ÓÃÀ´´¢´æ¡¢¶ÁÈ¡¡¢ÒÔ¼°´¦ÀíÊý¾Ý¿âÖ®ÖеÄ×ÊÁÏ¡£
- ±í¸ñ´¦Àí: SQL ÈçºÎ±»ÓÃÀ´´¦ÀíÊý¾Ý¿âÖеıí¸ñ¡£
- SQLÓï·¨: ÕâÒ»Ò³ÁгöËùÓÐÔÚÕâ¸ö½Ì²ÄÖб»Ìáµ½µÄ SQL Óï·¨
SQL SELECT
Store_Information ±í¸ñ ......

SQLÓïÑԵIJ¼¾ÖºÍIllegalArgumentException

ºÍjava.lang.IllegalArgumentException: org.hibernate.QueryException: JPA-style positional param was not an integral ordinalÕ½¶·ÁË°ëÌ죬º¹°¡£¡
ʹÓÃjpa + strut+ hibernate ¾Í±¨org.hibernate.QueryException: JPA-style positional param was not an integral ordinal
Ò»°ã°ÑhqlÓï¾äдÔÚÒ»ÐУ¬»áºÜ³¤£¬ÔÚideÖÐÐèÒ ......

access ·ÖÒ³Óà SQL²éѯÓï¾ä

select top ÿҳÏÔʾµÄ¼Ç¼Êý * from topic where id not in (select top £¨µ±Ç°µÄÒ³Êý-1£©×ÿҳÏÔʾµÄ¼Ç¼Êý id from topic order by id desc) order by id desc
select top ÿҳÏÔʾµÄ¼Ç¼Êý * from topic where id not in (select top £¨µ±Ç°µÄÒ³Êý-1£©×ÿҳÏÔʾµÄ¼Ç¼Êý id from topic order by id desc) ......

SQL Öн«Ò»¸ö±íת»¯³É½¨±íÓï¾äµÄ´æ´¢¹ý³Ì

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE proc pGetInsertSQL (@TableName varchar(256))
as
begin
    set nocount on
    declare @sqlstr varchar(4000)
    declare @sqlstr1 varchar(4000)
    declare @sqlstr2 v ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ