Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql query - contains?

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.

like image 610
JJunior Avatar asked Aug 12 '10 14:08

JJunior


People also ask

How do you check if a field contains a string in MySQL?

MySQL query string contains using LOCATE We will be using the LOCATE() function for the solution. LOCATE(substr, str) function returns the first occurrence of the substring passed in as parameters. Here substr is the substring passed in as the first argument, and str is the string passed in as the second argument.

Can we use contains in SQL?

CONTAINS is a predicate used in the WHERE clause of a Transact-SQL SELECT statement to perform SQL Server full-text search on full-text indexed columns containing character-based data types. CONTAINS can search for: A word or phrase. The prefix of a word or phrase.

How do you check if a column contains a value in MySQL?

Try this query: mysql_query(" SELECT * FROM `table` WHERE `column` LIKE '%{$needle}%' ");

How do you check if a string contains a word in SQL?

To check if string contains specific word in SQL Server we can use CHARINDEX function. This function is used to search for specific word or substring in overall string and returns its starting position of match. In case if no word found then it will return 0 (zero).


1 Answers

Try

AND i.description LIKE '% DBK%' 
like image 93
D'Arcy Rittich Avatar answered Nov 14 '22 04:11

D'Arcy Rittich