vendredi 20 février 2015

SQL search query using LIKE and WHERE

I need your help.


This is my Products Table:



id name type
1 item 1 A
2 item 2 A
3 item 3 B
4 item 4 B


etc...


I want to search all possible records which start with item in Type A


I have this query:



SELECT * FROM products
WHERE type = 'A'
OR name LIKE '%item%';


But I'm getting possible records from other types. How can I filter to only display Type A? Any ideas?


Aucun commentaire:

Enregistrer un commentaire