kamatchi
kamatchi

Reputation: 86

How to search record if field contain slashes in MySQL

I want to search records based on my erp_no my erp_no field is varchar in my table.

I am using the following query to search

SELECT * FROM `invoice` WHERE erp_no LIKE '%SORD\WH03\17\0002917%'

But it's returning the empty result set may I know what is the issue?

enter image description here

Upvotes: 1

Views: 41

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133370

You could use escaping sequence for backslash

 SELECT * FROM `invoice` WHERE erp_no LIKE '%SORD\\WH03\\17\\0002917%'

looking to your sample you should use

 SELECT * FROM `invoice` WHERE erp_no ='SORD\\WH03\\17\\0002917'

Upvotes: 2

Related Questions