views:

55

answers:

4

how can i search for a particular string in mysql? I tried using contains- gives me error:

SELECT r.name
     , r.network
     , r.namestring
     , i.name
     , r.rid
     , i.id
     , d.dtime
     , d.ifInOctets
     , d.description
FROM router AS r
INNER JOIN interface AS i ON r.rid = i.rid
INNER JOIN 1278993600_1_60 AS d ON i.id = d.id
                               AND d.dtime BETWEEN 1279027200 AND 1279029000
     WHERE r.network = "ITPN"
       AND i.status = "active"
       AND i.description CONTAINS ' DBK'

Please help.

+1  A: 

use like, i.e. AND i.description LIKE '%DBK%'

Michael Pakhantsov
Note there should be a leading space before `DBK`.
RedFilter
+1  A: 

Try

AND i.description LIKE '% DBK%' 
RedFilter
thank you so much!
jillika iyer
+3  A: 

Looking for LIKE:

AND i.description LIKE '% DBK%'

More Info:

Sarfraz
A: 

Try

...AND i.description like '% DBK%'

Or

...AND upper(i.description) like '% DBK%'

If you want to get anything with DBK, DbK, dbk, dBk, ...

FrustratedWithFormsDesigner
From my experiences, 'LIKE' is not case sensitive by default, so there is no need for 'UPPER()'.
pferate
@pferate: It varies. Oracle's `LIKE` is case-sensitive. I couldn't remember at the time I wrote, but MySQL's is case- *in* sensitive by default (just looked it up).
FrustratedWithFormsDesigner
Thanks. Good to know, I haven't worked with Oracle.
pferate