sqlÓï¾äÓÅ»¯2
£¨18£©ÓÃEXISTSÌæ»»DISTINCT£º
µ±Ìá½»Ò»¸ö°üº¬Ò»¶Ô¶à±íÐÅÏ¢(±ÈÈ粿ÃűíºÍ¹ÍÔ±±í)µÄ²éѯʱ,±ÜÃâÔÚSELECT×Ó¾äÖÐʹÓÃDISTINCT¡£Ò»°ã¿ÉÒÔ¿¼ÂÇÓÃEXISTÌæ»», EXISTS ʹ²éѯ¸üΪѸËÙ,ÒòΪRDBMSºËÐÄÄ£¿é½«ÔÚ×Ó²éѯµÄÌõ¼þÒ»µ©Âú×ãºó,Á¢¿Ì·µ»Ø½á¹û¡£Àý×Ó£º
(µÍЧ):
SELECT DISTINCT DEPT_NO,DEPT_NAME from DEPT D , EMP E
WHERE D.DEPT_NO = E.DEPT_NO
(¸ßЧ):
SELECT DEPT_NO,DEPT_NAME from DEPT D WHERE EXISTS ( SELECT ‘X'
from EMP E WHERE E.DEPT_NO = D.DEPT_NO);
£¨19£©SQLÓï¾äÓôóдµÄ£»ÒòΪOracle×ÜÊÇÏȽâÎöSQLÓï¾ä£¬°ÑСдµÄ×Öĸת»»³É´óдµÄÔÙÖ´ÐС£
£¨20£©ÔÚJava´úÂëÖо¡Á¿ÉÙÓÃÁ¬½Ó·û“£«”Á¬½Ó×Ö·û´®¡£
£¨21£©±ÜÃâÔÚË÷ÒýÁÐÉÏʹÓÃNOTͨ³££¬ÎÒÃÇÒª±ÜÃâÔÚË÷ÒýÁÐÉÏʹÓÃNOT, NOT»á²úÉúÔÚºÍÔÚË÷ÒýÁÐÉÏʹÓú¯ÊýÏàͬµÄÓ°Ïì¡£µ±Oracle“Óöµ½”NOT,Ëû¾Í»áֹͣʹÓÃË÷Òýת¶øÖ´ÐÐÈ«±íɨÃè¡£
£¨22£©±ÜÃâÔÚË÷ÒýÁÐÉÏʹÓüÆËã¡£WHERE×Ó¾äÖУ¬Èç¹ûË÷ÒýÁÐÊǺ¯ÊýµÄÒ»²¿·Ö¡£ÓÅ»¯Æ÷½«²»Ê¹ÓÃË÷Òý¶øʹÓÃÈ«±íɨÃè¡£
¾ÙÀý:
µÍЧ£º
SELECT … from DEPT WHERE SAL * 12 > 25000;
¸ßЧ:
SELECT … from DEPT WHERE SAL > 25000/12;
£¨23£©ÓÃ>=Ìæ´ú>£º
¸ßЧ:
SELECT * from EMP WHERE DEPTNO >=4
µÍЧ:
SELECT * from EMP WHERE DEPTNO >3
Á½ÕßµÄÇø±ðÔÚÓÚ, Ç°ÕßDBMS½«Ö±½ÓÌøµ½µÚÒ»¸öDEPTµÈÓÚ4µÄ¼Ç¼¶øºóÕß½«Ê×Ïȶ¨Î»µ½DEPTNO=3µÄ¼Ç¼²¢ÇÒÏòǰɨÃèµ½µÚÒ»¸öDEPT´óÓÚ3µÄ¼Ç¼¡£
£¨24£©ÓÃUNIONÌæ»»OR (ÊÊÓÃÓÚË÷ÒýÁÐ)£º
ͨ³£Çé¿öÏÂ, ÓÃUNIONÌæ»»WHERE×Ó¾äÖеÄOR½«»áÆ𵽽ϺõÄЧ¹û¡£¶ÔË÷ÒýÁÐʹÓÃOR½«Ôì³ÉÈ«±íɨÃè¡£×¢Òâ, ÒÔÉϹæÔòÖ»Õë¶Ô¶à¸öË÷ÒýÁÐÓÐЧ. Èç¹ûÓÐcolumnûÓб»Ë÷Òý, ²éѯЧÂÊ¿ÉÄÜ»áÒòΪÄãûÓÐÑ¡ÔñOR¶ø½µµÍ¡£ÔÚÏÂÃæµÄÀý×ÓÖÐ, LOC_ID ºÍREGIONÉ϶¼½¨ÓÐË÷Òý¡£
¸ßЧ:
SELECT LOC_ID , LOC_DESC , REGION
from LOCATION
WHERE LOC_ID = 10
UNION
SELECT
Ïà¹ØÎĵµ£º
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......
Table-Naming Standards
Table-naming standards, as well as any standard within a business, are critical to
maintaining control. After studying the tables and data in the previous sections, you
probably noticed that each table’s suffix is _TBL. This is a naming standard selected
for use, suc ......
ÔÚÊý¾Ý¿âÓ¦ÓõÄÉè¼ÆÖУ¬ÎÒÃÇÍùÍù»áÐèÒª»ñȡijЩ±íµÄ¼Ç¼×ÜÊý£¬ÓÃÓÚÅжϱíµÄ¼Ç¼×ÜÊýÊÇ·ñ¹ý´ó£¬ÊÇ·ñÐèÒª±¸·ÝÊý¾ÝµÈ¡£ÎÒÃÇͨ³£µÄ×ö·¨ÊÇ£ºselect count(*) as c from tableA ¡£È»¶ø¶ÔÓڼǼÊý¾Þ´óµÄ±í£¬ÉÏÊö×ö·¨½«»á·Ç³£ºÄʱ¡£ÔÚDELL 4400 ·þÎñÆ÷ÉÏ×öÊÔÑ飬MS Sqlserver 2000 Êý¾Ý¿â¶ÔÓÚ100Íò¼Ç¼µÄ¼òµ¥Êý¾Ý±íÖ´ÐÐÉÏÊöÓï¾ä£¬Ê± ......
--sqlÓï¾ä¾ÍÓÃÏÂÃæµÄ´æ´¢¹ý³Ì
/*--Êý¾Ýµ¼³öExcel
µ¼³ö²éѯÖеÄÊý¾Ýµ½Excel,°üº¬×Ö¶ÎÃû,ÎļþΪÕæÕýµÄExcelÎļþ
,Èç¹ûÎļþ²»´æÔÚ,½«×Ô¶¯´´½¨Îļþ
,Èç¹û±í²»´æÔÚ,½«×Ô¶¯´´½¨±í
»ùÓÚͨÓÃÐÔ¿¼ÂÇ,½öÖ§³Öµ¼³ö±ê×¼Êý¾ÝÀàÐÍ
--×Þ½¨ 2003.10--*/
/*--µ÷ÓÃʾÀý
p_exporttb @sqlstr='select * from µØÇø×ÊÁÏ'
,@path='c:\',@fn ......