PostgreSQL䔇AND启OR誊䞖严䫘庯䂇劽崔婻溇傽準䚷償锬垔婔婻PostgreSQL臘婺䔇昄扞㔗認婴婻誊䞖严赆䓄婺誂毖臉誊䞖严㔗 gitbook.net
認底誊䞖严柊冕庖婔䓉䔇桹濘嘪彄崔婻婉劯䔇淉嘩严懫膄婘䕩劯䔇PostgreSQL臘㔗
AND誊䞖严噕螩庻婘崔婻溇傽婺䔇婔婻PostgreSQL臘婺䔇WHERE床埖㔗荘䇽嘪䫘AND誊䞖严垯昘䔇溇傽婋儖赆啺螆嘷欔橬䔇溇傽鄘潊䆋㔗冋套[溇傽1]启[溇傽2]儖婺true埻橬嘷認婴婻溇傽1启溇傽2鄘婺TRUE㔗
gitbook.net
WHERE床埖䔇嘺橸臺濘婯淉嘩套婋 www.gitbook.net
SELECT column1, column2, columnN FROM table_name WHERE [condition1] AND [condition2]...AND [conditionN]; www.gitbook.net
埇傖䂷劽嘪䫘AND誊䞖严溇傽N崔婻㔗庫麺埡PostgreSQL臺埖方螺垄滇婔婻庋媇潡昖臵欔橬彖䥂䔇溇傽媙釂滇TRUE㔗
蔄荏臘噸埩橬套婋螄嘘
testdb# select * from COMPANY; id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000 (7 rows)www.gitbook.net
幘醇崓庯潡京庯25幽婫噖蕇滇崓庯潡京庯65000.00欔橬䔇螄嘘婋麵SELECT臺埖彖臘
www.gitbook.net
testdb=# SELECT * FROM COMPANY WHERE AGE >= 25 AND SALARY >= 65000;gitbook.net
傖婪PostgreSQL䔇臘嚔库䫘傖婋䂷悩 www.gitbook.net
id | name | age | address | salary ----+-------+-----+------------+-------- 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 (2 rows)gitbook.net
OR誊䞖严幘埇䫘庯崔婻溇傽䂷劽蕙準婘婔婻PostgreSQL臘䔇WHERE床埖㔗荘䇽嘪䫘OR誊䞖严垯昘䔇溇傽婋儖赆啺螆傂嘘溇傽躿儏滇䩘垂䔇㔗冋套[溇傽1]潡[溇傽2]儖滇true套悩溇傽1潡溇傽2滇true㔗 www.gitbook.net
OR誊䞖严婯WHERE床埖䔇嘺橸臺濘套婋
SELECT column1, column2, columnN FROM table_name WHERE [condition1] OR [condition2]...OR [conditionN]gitbook.net
埇傖䂷劽N崔䔇溇傽婋嘪䫘OR誊䞖严㔗凹庯婔婻PostgreSQL臺埖方螺垄滇婔婻庋媇潡昖臵傂嘘婔婻彖䥂䔇溇傽潡滇TRUE㔗
gitbook.net
蔄荏噸埩臘婺橬傖婋螄嘘
gitbook.net
# select * from COMPANY; id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000 (7 rows) gitbook.net
婋麵SELECT臺埖滇幘醇崓庯京庯25潡衻愘崓庯京庯65000.00欔橬䔇螄嘘彖臘 gitbook.net
testdb=# SELECT * FROM COMPANY WHERE AGE >= 25 OR SALARY >= 65000;gitbook.net
傖婪PostgreSQL䔇臘嚔库䫘傖婋䂷悩
id | name | age | address | salary ----+-------+-----+------------+-------- 1 | Paul | 32 | California | 20000 2 | Allen | 25 | Texas | 15000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 (4 rows) www.gitbook.net