where 条件使用 本文为您介绍如何在使用SELECT语法时添加where条件。 单条件查询 plaintext teledb select from teledbpg where id 1; id nickname + 1 teledb 1 hello,pgxc (2 rows) 多条件and plaintext teledb select from teledbpg where id 1 and nickname like '%h%' ; id nickname + 1 hello,pgxc (1 row) 多条件or plaintext teledb select from teledbpg where id 1 or nickname like '%p%' ; id nickname + 1 teledb 1 hello,pgxc 3 pg (3 rows) ilike 不区分大小写匹配 plaintext teledb insert into teledbpg values(2,'TELEDB'); INSERT 0 1 teledb select from teledbpg where nickname ilike '%te%'; id nickname + 1 teledb 2 TELEDB (2 rows) where 条件也能支持子查询 plaintext teledb select from teledbpg where id(select (random())::integer from teledbpg order by random() limit 1); id nickname + (0 rows) teledb select from teledbpg where id(select (random())::integer from teledbpg order by random() limit 1); id nickname + 1 teledb 1 hello,pgxc (2 rows) null 值查询方法 plaintext teledb select from teledbpg where nickname is null; id nickname + 4 (1 row) teledb select from teledbpg where nickname is not null; id nickname + 1 teledb 3 pg 1 hello,pgxc 2 TELEDB (4 rows) exists 只要有记录返回就为真 plaintext teledb