åµå¥SELECTè¯å¥ä¹å«åæ¥è¯¢ï¼ä¸ä¸ª SELECT è¯å¥çæ¥è¯¢ç»æè½å¤ä½ä¸ºå¦ä¸ä¸ªè¯å¥çè¾å
¥å¼ãåæ¥è¯¢ä¸ä½è½å¤åºç°å¨Whereåå¥ä¸ï¼ä¹è½å¤åºç°å¨fromåå¥ä¸ï¼ä½ä¸ºä¸ä¸ªä¸´æ¶è¡¨ä½¿ç¨ï¼ä¹è½å¤åºç°å¨select listä¸ï¼ä½ä¸ºä¸ä¸ªå段å¼æ¥è¿åã
1ãåè¡åæ¥è¯¢ ï¼åè¡åæ¥è¯¢æ¯æåæ¥è¯¢çè¿åç»æåªæä¸è¡æ°æ®ãå½ä¸»æ¥è¯¢è¯å¥çæ¡ä»¶è¯å¥ä¸å¼ç¨åæ¥è¯¢ç»ææ¶å¯ç¨åè¡æ¯è¾ç¬¦å·ï¼ï¼, >, <, >=, <=, <>ï¼æ¥è¿è¡æ¯è¾ã ä¾ï¼
select ename,deptno,sal from emp
where deptno=(select deptno from dept where loc='NEW YORK');
2ãå¤è¡åæ¥è¯¢ï¼å¤è¡åæ¥è¯¢å³æ¯åæ¥è¯¢çè¿åç»ææ¯å¤è¡æ°æ®ãå½ä¸»æ¥è¯¢è¯å¥çæ¡ä»¶è¯å¥ä¸å¼ç¨åæ¥è¯¢ç»ææ¶å¿
é¡»ç¨å¤è¡æ¯è¾ç¬¦å·ï¼INï¼ALL,ANYï¼æ¥è¿è¡æ¯è¾ãå
¶ä¸ï¼INçå«ä¹æ¯å¹é
åæ¥è¯¢ç»æä¸çä»»ä¸ä¸ªå¼å³å¯ï¼"IN" æä½ç¬¦ï¼è½å¤æµè¯æ个å¼æ¯å¦å¨ä¸ä¸ªå表ä¸ï¼ï¼ALLåå¿
é¡»è¦ç¬¦ååæ¥è¯¢çææå¼æå¯ï¼ANYè¦ç¬¦ååæ¥è¯¢ç»æçä»»ä½ä¸ä¸ªå¼å³å¯ãèä¸é¡»æ³¨æALL åANY æä½ç¬¦ä¸è½åç¬ä½¿ç¨ï¼èåªè½ä¸åè¡æ¯è¾ç¬¦ï¼=ã>ã< ã>= ã<= ã<>ï¼ç»å使ç¨ã ä¾ï¼
1ï¼.å¤è¡åæ¥è¯¢ä½¿ç¨INæä½ç¬¦å·ä¾åï¼
æ¥è¯¢éä¿®äºèå¸åå«Rona(å设å¯ä¸)çå¦çåå
sql> select stName from Student
where stId in(selectdistinct stId from score where teId=(select teId from teacher where teName='Rona'));
æ¥è¯¢ææé¨é¨ç¼å·ä¸ºAçèµæï¼ SELECT ename,job,sal FROM EMP
WHERE deptno in ( SELECT deptno FROM dept WHERE dname LIKE 'A%');
2ï¼.å¤è¡åæ¥è¯¢ä½¿ç¨ALLæä½ç¬¦å·ä¾åï¼æ¥è¯¢æä¸é¨ä»¥ä¸çæ绩é«äºKakaçæé«æ绩çå¦ççåå: sql> select stName from Student
where stId in(select distinct stId from score where score >all(select score from score where stId=(select stId from Student where stName= 'Kaka') )); 3ï¼. å¤è¡åæ¥è¯¢ä½¿ç¨ANYæä½ç¬¦å·ä¾åï¼æ¥è¯¢æä¸é¨ä»¥ä¸çæ绩é«äºKakaçä»»ä½ä¸é¨æ绩çå¦ççåå:
sql> select stName from Student
where stId in(select distinct stId from score where score >any(select score from score where stId=(select stId from Student where stName='Kaka')));
å¸æè½å¸®å°ä½
温馨提示:内容为网友见解,仅供参考