0

I have comma separated data in DB where each comma separated data is in new line like below

Computer Accessories,

Laptop Dealers,

CCTV Dealers,

computer sales,

computer service center

When i execute a query with LIKE "%,computer sales,%", its not returning any value. how to remove the extra spaces or is there any query which will consider the space and return value

1 Answers1

0

Please try the below:

where COL rlike '[:space:]*computer sales,[:space:]*'
Harika B
  • 83
  • 9
  • It is working fine but is it correct if i write it as rlike '[:space:]*".$category.",[:space:]*' in php prepared statement –  Jul 12 '16 at 09:17
  • It should work as per my understanding. Please give it a try! – Harika B Jul 12 '16 at 09:22
  • It worked for every data apart from the last one as there is no comma –  Jul 12 '16 at 09:29
  • did u mention the condition for the last one as: COL rlike '[:space:]*computer service center[:space:]*' .. ? (without comma) – Harika B Jul 12 '16 at 09:53