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,000 points
4,108 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,600 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,690 points
1,583 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
27,101 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
2,112 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,070 points
1,651 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,350 points
1,825 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,640 points
1,913 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
1,043 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,600 points
690 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,600 points
5,817 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