Wednesday, 2 October 2013

How to use REGEXP in MySQL to aquire specific columns

How to use REGEXP in MySQL to aquire specific columns


Recently i tried without successes ask MySQL DB for specific data:
SELECT code, txt_gb, txt_de FROM table WHERE code REGEXP 'chol'OR txt_gb
REGEXP 'chol' OR txt_de REGEXP 'chol' ORDER BY code COLLATE
utf8_unicode_ci
My goal is to acquire every row in which specific columns containts 'chol'
substring. I need as you see only some colums (there are more int this
table). I recieve whole table. Or maybe not whole but on first look there
are too many rows.
I created this query in JavaSE, but i don't see a reason why shoud it
interfere with asking DB.
Another thing.
I read somwhere, LIKE command has better performance that REGEXP. Is it
true? Can i use in this case LIKE instead of REGEXP to find part of cell?
I am very interesting in small load of DB.
Regards.

No comments:

Post a Comment