Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have the following table:

CREATE TABLE lawyer (
  id SERIAL PRIMARY KEY,
  name VARCHAR NOT NULL UNIQUE,
  name_url VARCHAR check(translate(name_url, 'abcdefghijklmnopqrstuvwxyz-', '') = '') NOT NULL UNIQUE
);

I want to SELECT * FROM lawyer where name_url = "john-doe"

like image 277
Jeka Avatar asked Jun 16 '16 20:06

Jeka


1 Answers

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

like image 79
a_horse_with_no_name Avatar answered Sep 26 '22 01:09

a_horse_with_no_name