LeoSam
LeoSam

Reputation: 4941

mysql query for finding names include special character single quotes

I'm looking for an SQL statement that will return only rows of my table whose Name field contains special characters (single quotes).

I used

  SELECT * FROM 'table' WHERE Name REGEXP '"$'

What do i miss to put here ?

Upvotes: 1

Views: 3429

Answers (3)

Ankur Trapasiya
Ankur Trapasiya

Reputation: 2200

SQL Fiddle

MySQL 5.5.30 Schema Setup:

create table test(name varchar(10));

insert into test
values('aaa '''' bb'),('bsbds');

Query 1:

select *
from test
where name regexp "'"

Results:

|      NAME |
-------------
| aaa '' bb |

Upvotes: 2

vjy
vjy

Reputation: 1204

For single quotes alone

select * from `table` WHERE Name REGEXP "'";

If you need more special symbols like ' % $

select * from `table` WHERE Name REGEXP "['%$]";

Upvotes: 1

Salil
Salil

Reputation: 47482

SELECT * FROM 'table' WHERE Name like "%\'%"

Upvotes: 2

Related Questions