I made a database and a table in it with different types of cars, and in the table, there are two with the brand Toyota among other brands.
I then tried to search the entire table using SELECT * FROM Car WHERE Make='Toyota'; but only one row appeared.
This is the code with the information that was brought up:
>Solution :
The problem is that your query tries to match exactly 6 characters "Toyota", whereas your input samples may have hidden spaces. If you want this query to work, you either check that there are no leading and trailing spaces or use one of the following solutions:
Option 1: the TRIM function removes leading and trailing spaces
SELECT *
FROM Car
WHERE TRIM(Make) = 'Toyota';
Option 2: the LIKE statement will allow you to get any string that has the word "Toyota" in it (% is a wildcard for "any string"):
SELECT *
FROM Car
WHERE Make LIKE '%Toyota%';
Note: These queries will work with the MySQL DBMS. If you have a different DBMS, add it in your problem statement as tag.
