-3

Sorry if my question is a newbiew question :(

I just want to search some record that have some values of text.

Example, I have table like this: enter image description here

Can you write for me the query to find a record that contains 'Robot' in description column.

I don't want to use LIKE query.

Thanks all

sagi
  • 40,026
  • 6
  • 59
  • 84

2 Answers2

0

I don't see any reason not to use LIKE, but anyway:

SELECT * FROM sakila WHERE description REGEXP 'Robot'
mitkosoft
  • 5,262
  • 1
  • 13
  • 31
-1

You are looking for LIKE :

SELECT * FROM YourTable
WHERE description LIKE '%Robot%'

If you don't want to use LIKE then:

SELECT * FROM YourTable 
WHERE INSTR(description, 'Robot') > 0
sagi
  • 40,026
  • 6
  • 59
  • 84
  • Probably someone who thinks there's a better way than LIKE. – jarlh Feb 25 '16 at 08:41
  • but, what if there is a Robot in the first of the statement, like this : "Robot is a .... ", you cant use LIKE %Robot% right? – Ilham Mulyawinata Feb 25 '16 at 08:42
  • So it will still be returned, % means that any thing can replace it(including nothing) any way i posted an answer without like – sagi Feb 25 '16 at 08:43
  • This answer is correct. I found a good discussion in case you want to find different ways of using SELECT statements with WHERE clauses using both 'like' and '=' operators. [link](http://stackoverflow.com/a/543740/4438391) – Diego Vidal Feb 25 '16 at 08:45
  • Can be improved, till return XYZRobototos rows as well. – jarlh Feb 25 '16 at 08:47
  • And you know he don't want this row? @jarlh I can add space there but I don't know if this what he wants – sagi Feb 25 '16 at 08:48