Reputation: 91
I am working with a product database and i need to select products
that are greater than £150 also only entries that have "HP" in the third and forth position of the prod_id
.
So far i have tried
SELECT * FROM products WHERE prod_id LIKE 'hp%';
Here is a pic of the table i need to query
Upvotes: 0
Views: 1293
Reputation: 8797
SELECT * FROM products WHERE prod_id LIKE '__hp%' and price > 150;
"_" (underscore) is any symbol (there are 2 undrscores in this query)
Upvotes: 2
Reputation: 15865
An underscore will match a single character.
So:
SELECT * FROM products
WHERE prod_id LIKE '__hp%'
AND price > 150;
Should find all products whos 3rd and 4th character are hp and have a price of 150 or more
Upvotes: 2