MySQL: select the row in which the column contains an item from the list.

I am trying to select all the rows from a table where the column contains an item from the list: Something like

Select * from `table` where `column` (contains anything from {£,$,%,^,&,...,/})

This is mainly an illegal character check.

Can anyone help?

thank

+5
source share
4 answers

For MySQL, you can use REGEXPor RLIKEto check a specific column for pattern matching. In your case, the following example might work:

SELECT * FROM `table` WHERE `column` REGEXP '[\£\$\%\^\&]';
+9
source

You can use LIKEto match patterns,

SELECT  *
FROM    `table`
WHERE   `column` LIKE '%£%' OR
        `column` LIKE '%$%' OR
        `column` LIKE '%\%%' OR
        `column` LIKE '%&%'
0
source

, , - ,

SELECT * FROM `table` WHERE `column` REGEXP '^[^a-zA-Z0-9]+$'

^ [ ] charcter , . $

0
source
SELECT * FROM table WHERE column LIKE '%\%%' OR column LIKE '%$%' OR column LIKE '%&%';

... etc .. '% char%' means that there is char somewhere, '% char' means that char is at the end of the line, 'char%' means that it is at the beginning. '% \ %%' means that the char search (%) is the special char used by mysql, and '\' is necessary.

0
source

All Articles