Postgres SELECT* FROM table WHERE column-varchar==“string-example”?

半世苍凉 提交于 2019-12-04 12:57:01

Character literals are put into single quotes:

SELECT * 
FROM lawyer 
where name_url = 'john-doe';

See the manual for details:
https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS

Looking for exact match:

select column1, column2 from mytable where column2 like 'string';

Pattern Match can be achieved using:(returns stringxx, stringyyy..)

select column1, column2 from mytable where column2 like 'string%';

This will return any column2 that matches string***.

For using OR condition, to compare multiple strings below one can be used:

select column1, column2 from mytable where column2 ~* 'string1|string2';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!