LeoSam
LeoSam

Reputation: 4941

select data with single quote only- Postgres

im using Like to select all data which has single quote in name like Jon's.

select * from users where file_name like '%'%';

I then want to remove the ' from all results.

Ideas?

Upvotes: 0

Views: 1663

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324521

Double quotes in SQL to escape them:

select * from users where file_name like '%''%';

(For any vaguely recent PostgreSQL version; the non-standard escape-string phrasing E'%\'%' will work with even very old PostgreSQL versions, but not other databases.)

It sounds like you want to remove those characters from the file names. If so, something like the untested:

update users
set file_name = replace(file_name, '''', '')

should do the trick.

Upvotes: 2

Related Questions