WHERE µu¥y¤ÎÀ˯Á±ø¥ó

«e­¶ ¥Ø¿ý ¤U­¶

¦³®É­Ô¡A§Ú­Ì¥u·Q®³¨ú²Å¦X¬Y­Ó±ø¥óªº°O¿ý¡C­n¹F¨ì³o­Ó¥Øªº¡A§Ú­Ì¥i¥H¦b SELECT »y¥y¤¤¨Ï¥Î WHERE µu¥y¡C

¦b SELECT »y¥y¤¤¨Ï¥Î WHERE µu¥yªº»yªk¦p¤U¡J

SELECT <¦r¬q¦Cªí> FROM <ªíªº¦WºÙ> WHERE <À˯Á±ø¥ó>

¥u¦³²Å¦X <À˯Á±ø¥ó> ªº°O¿ý¤~·|³Q®³¨ú¡C

SQL ´£¨Ñ¤F¤@¨t¦C¹Bºâ²Å©MÃöÁä¦r¥hªí¹F <À˯Á±ø¥ó>¡C¦b³oùاڭ̰Q½×¥H¤U¦U¶µ¡J

¤ñ¸û¹Bºâ²Å  

SQL ´£¨Ñªº¤ñ¸û¹Bºâ²Å©M Pascal ªº¤@¼Ë¡J

¹Bºâ²Å = > < >= <= <>
·N¸q ¬Ûµ¥ ¤j©ó ¤p©ó ¤j©ó©Î¬Ûµ¥ ¤p©ó©Î¬Ûµ¥ ¤£µ¥©ó

WHERE µu¥y¨Ï¥Î¤ñ¸û¹Bºâ²Åªº¤èªk¦p¤U¡J

WHERE <ºâ¦¡> <¤ñ¸û¹Bºâ²Å> <ºâ¦¡>

¤@­Ó <ºâ¦¡> ¥i¥H¬O¤@­Ó±`¼Æ¡B¤@­Ó¦r¬q¦WºÙ©Î¥Ñºâ³N¹Bºâ²Å¡]¨Ò¦p +¡B-¡B*¡B /¡^¤Î¬A¸¹³s±µ¦¨¥H¤W¦U¼Ëªº¥ô¦ó²Õ¦X¡C

¨Ò¦p¡J

¦C¥X©Ò¦³¦b¤¤°ê»y¤å¤Î¤å¤Æ¬ì¤Î®æ¡]>= 50¡^ªº¦P¾Çªº¯Z¸¹¡B©m¦W¤Î¤¤°ê»y¤å¤Î¤å¤Æ¬ìªº¤À¼Æ¡C
SELECT class_num, name, clc FROM s6a WHERE clc >= 50
¿é¥X¡J
class_num name clc
1 Chan Wai Man, Raymond 64
2 Chow Chi Ling 70
3 Fung Ching Man, Mandy 72
4 Hung Wai Ming 52
6 Poon Kwok Fai 59
7 Sung Hing Wah, Patrick 70
8 Tang Wing Chi 80
10 Yeung Chun 69
11 Lai Fung Chun 78
13 Man Fook Wing 55
14 Chung Kwok Fai, Fred 72
15 Lee Lai May 67
¡@
¦C¥X©Ò¦³¥­§¡¤À¤£¤Î®æ¡]< 50¡^ªº¦P¾Çªº¯Z¸¹¤Î©m¦W¡C
SELECT class_num, name FROM s6a WHERE (clc + ue + pm + phy + cs) / 5 < 50
¿é¥X¡J
class_num name
5 Leung King
9 Wong Ka Tak, Kent

¦p Pascal ¤@¼Ë¡A§Ú­Ì¥i¥H¨Ï¥Î¤ñ¸û¹Bºâ²Å¥h¤ñ¸û¦r²Åºâ¦¡¡C¦r²Å¬O¸ò¾Ú­^¤å¦r¥À¶¶§Ç±Æ¦C¡F¤£¹L¡A¤j¤p·¢¦³¨S¦³¤À§O©M¨Ï¥Îªº¨t²Î¦³Ãö¡C¹ï©ó Microsoft Visual FoxPro ¤Î Microsoft Access ¨Ó»¡¡A¤j¤p·¢¬O¨S¦³¤À§Oªº¡C

¨Ò¦p¡J

¦C¥X©Ò¦³¾Ç¥Í½s¸¹¬O¡u93¡v©Î¥H¤W¶}ÀYªº°O¿ý¡J
SELECT * FROM s6a WHERE stud_id >= '93'
¿é¥X¡J
class_num stud_id name email clc ue phy pm cs
3 94302 Fung Ching Man, Mandy mandyfung@example.com 72 50 42 59 60
8 97602 Tang Wing Chi s97602@sample.edu.hk 80 79 70 72 69
10 93211 Yeung Chun cyeung@testing.com.hk 69 80 77 60 52
11 96374 Lai Fung Chun s96374@sample.edu.hk 78 75 69 65 61
12 94412 Chan Lai Yin cly@testing.com.hk 43 59 53 61 60
13 98832 Man Fook Wing fwman@testing.com.hk 55 77 34 40 51
14 95343 Chung Kwok Fai, Fred fredchung@example.com 72 62 53 47 50
15 97233 Lee Lai May maylee@testing.com.hk 67 71 56 60 55

±ø¥óªº²Õ¦X¡]AND¡BOR¡^  

¹Bºâ²Å AND ¤Î OR ªº¨Ï¥Î¤èªk©M¨ä¥Lªºµ{§Ç»y¨¥©Ò¨£ªº¤@¼Ë¡J

¦C¥X©Ò¦³¤¤°ê»y¨¥¤Î¤å¤Æ©M­^»y¹B¥Î¨â¬ì³£¤Î®æªº¦P¾Çªº¯Z¸¹¡B©m¦W¤Î¤¤°ê»y¤å¤Î¤å¤Æ¬ì¤Î¹B¥Î­^»yªº¤À¼Æ¡J
SELECT class_num, name, clc, ue FROM s6a WHERE clc >= 50 AND ue >= 50
¿é¥X¡J
class_num name clc ue
1 Chan Wai Man, Raymond 64 55
2

Chow Chi Ling

70 62
3 Fung Ching Man, Mandy 72 50
6 Poon Kwok Fai 59 60
7 Sung Hing Wah, Patrick 70 72
8 Tang Wing Chi 80 79
10 Yeung Chun 69 80
11 Lai Fung Chun 78 75
13 Man Fook Wing 55 77
14 Chung Kwok Fai, Fred 72 62
15 Lee Lai May 67 71
¡@
¦C¥X©Ò¦³¦b¤¤°ê»y¤å¤Î¤å¤Æ¬ì©Î­^»y¹B¥Î¤£¤Î®æ¡]¨ä¤¤¤@¬ì©Î¨â¬ì³£¤£¤Î®æ§¡¥i¡^ªº¦P¾Çªº¯Z¸¹¡B©m¦W¤Î¤¤°ê»y¤å¤Î¤å¤Æ¬ì¤Î­^»y¹B¥Î¬ìªº¤À¼Æ¡J
SELECT class_num, name, clc, ue FROM s6a WHERE clc < 50 OR ue < 50
¿é¥X¡J
class_num name clc ue
4 Hung Wai Ming 52 48
5 Leung King 40 50
9 Wong Ka Tak, Kent 35 40
12 Chan Lai Yin 43 59

½d³ò¡]BETWEEN ¡K AND¡^  

WHERE µu¥y¤¤¥i¥H³o¼Ë¨Ï¥Î BETWEEN ¡K AND¡J

WHERE <ºâ¦¡> BETWEEN <­È1> AND <­È2>

³o WHERE µu¥yªí¥ÜÀ˯Á±ø¥ó¬O <ºâ¦¡> ¦b <­È1> ©M <­È2> ¤§¶¡¡]¥]¬A­º§À¤G¶µ¡^¡C¦]¦¹¡A³o WHERE µu¥y©M¥H¤Uªº¬Û¦P¡J

WHERE <ºâ¦¡> >= <­È1> AND <ºâ¦¡> <= <­È2>

¨Ò¦p¡J

¦C¥X©Ò¦³¦b¹q¸£¬ìÀò±o 50 ¦Ü 59 ¤À¡]¥]¬A­º§À¤G­È¡^ªº¦P¾Çªº¯Z¸¹¡B©m¦W¤Î¹q¸£¬ìªº¤À¼Æ¡C
SELECT class_num, name, cs FROM s6a WHERE cs BETWEEN 50 AND 59
¿é¥X¡J
class_num name cs
1 Chan Wai Man, Raymond 59
4 Hung Wai Ming 59
10 Yeung Chun 52
13 Man Fook Wing 51
14 Chung Kwok Fai, Fred 50
15 Lee Lai May 55

ª`·N¡J¦pªGÀ˯Á±ø¥ó­n¨Dªº½d³ò¤£¥]¬A­º§À¤G¶µ¡A§Ú­Ì¤@©w­n¨Ï¥Î¹Bºâ²Å > ¤Î <¡C

¦Cªí¡]IN¡^  

ÃöÁä¦r IN Åý¨Ï¥ÎªÌ¿ï¾Ü¤@­Ó¦Cªíªº­È¤¤¥ô¦ó¤@­Ó¡C¨Ò¦p¡J

¦C¥X©Ò¦³¦b¹q¸£¬ìÀò±o 50¡B60¡B70¡B80 ©Î 90 ¤Àªº¦P¾Çªº¯Z¸¹¡B©m¦W¤Î¹q¸£¬ìªº¤À¼Æ¡C
SELECT class_num, name, cs FROM s6a WHERE cs IN (50, 60, 70, 80, 90)
¿é¥X¡J
class_num name cs
2

Chow Chi Ling

70
3 Fung Ching Man, Mandy 60
5 Leung King 60
7 Sung Hing Wah, Patrick 70
12 Chan Lai Yin 60
14 Chung Kwok Fai, Fred 50

¥H¤Wªº SQL »y¥y©M¥H¤Uµ¥¦P¡J

SELECT class_num, name, cs FROM s6a
  WHERE cs = 50 OR cs = 60 OR cs = 70 OR cs = 80 OR cs = 90)