SQL like search string starts with

0 votes

Studying SQL. Have a straightforward table game with a field name. I want to perform a title-based search. The search returns the record with that name if I have a game called Age of Empires III: Dynasties and I use LIKE with the parameter Age of Empires III: Dynasties. However, a search in Age of Empires III yields no results:

SELECT * from games WHERE (lower(title) LIKE 'age of empires III');

This doesn't return anything. Should I be using something else instead of LIKE?

Sep 17, 2022 in Database by Kithuzzz
• 38,010 points
3,567 views

1 answer to this question.

0 votes
SELECT * from games WHERE (lower(title) LIKE 'age of empires III');

Because the exact string "age of empires III" isn't found in any records, the query mentioned above doesn't provide any results.

Therefore, you must use "%your string goes here%" to match this string with another string with "age of empires" as a substring.

More on MySQL string comparison

Try this

SELECT * from games WHERE (lower(title) LIKE '%age of empires III%');

In Like '%age of empires III%' this will search for any matching substring in your rows, and it will show in results.

answered Sep 18, 2022 by narikkadan
• 63,700 points

Related Questions In Database

0 votes
0 answers

If Cell Starts with Text String... Formula

I have formula that checks if the ...READ MORE

Feb 24, 2022 in Database by Edureka
• 13,670 points
1,478 views
0 votes
2 answers

Write a SQL query to find the names of employees that begin with ‘S’

Select ename From emp Where ename like"s%"; READ MORE

answered Oct 7, 2021 in Database by anonymous
25,730 views
0 votes
1 answer

How will I get all the rows from my table where name starts with 's' and ending with 'I'?

Hi Santanu, I understand your problem, You can try ...READ MORE

answered May 28, 2019 in Database by sampriti
• 1,120 points
1,775 views
0 votes
1 answer

two back slash in SQL procedure with Regular expression

It's the escape prefix in regular expressions: ...READ MORE

answered Feb 2, 2022 in Database by Vaani
• 7,060 points
1,391 views
0 votes
1 answer

Which query to use for better performance, join in SQL or using Dataset API?

DataFrames and SparkSQL performed almost about the ...READ MORE

answered Apr 19, 2018 in Apache Spark by kurt_cobain
• 9,390 points
1,572 views
0 votes
1 answer

How to connect Java program to the MySQL database?

You can connect your Java code with ...READ MORE

answered May 11, 2018 in Java by Parth
• 4,630 points
1,669 views
0 votes
1 answer
0 votes
1 answer

Automating Oracle script with nolio

Depending upon the details of your script ...READ MORE

answered Jul 17, 2018 in Other DevOps Questions by ajs3033
• 7,300 points
776 views
0 votes
1 answer

SQL Server WITH statement

I'm going to guess because I don't ...READ MORE

answered Sep 10, 2022 in Database by narikkadan
• 63,700 points
470 views
0 votes
1 answer

How to calculate percentage with a SQL statement

The following has passed my tests, and ...READ MORE

answered Sep 12, 2022 in Database by narikkadan
• 63,700 points
5,049 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP