Kusum February 2016

SQL Like Operator

Expected Output:

enter image description here

How can we run a query that returns "Robot" followed by a year between 2000 and 2099? (So 2015 is a valid value at the end, but 2123 is not.)

enter image description here

Answers


D. Zillig February 2016

SELECT id, name FROM robots WHERE name LIKE '%robot 20%' ORDER BY id


dnoeth February 2016

SELECT name FROM robots WHERE name LIKE '%Robot 20__%'

If there might be other characters after 20 you need REGEXP:

SELECT name FROM robots 
WHERE name REGEXP 'Robot 20[0-9][0-9]'


BKO February 2016

Try this,

SELECT name FROM robots WHERE name LIKE '%Robot 20%'


Kusum February 2016

Got the answer:

SELECT id, name FROM robots WHERE name LIKE '%Robot 20%_%'

Post Status

Asked in February 2016
Viewed 3,133 times
Voted 10
Answered 4 times

Search




Leave an answer