Sql Query Criteria
Posted: Sat May 12, 2007 7:42 pm
input search string : "HP COMPUTERS"
I would like to make a search query to my database and return the search result if it mathes.
Currently it only returns the result when it matches the word "HP COMPUTERS" within the description.
What i want is it also returns the result if the field contains "HP personal COMPUTERS" or "COMPUTERS personal HP".
The sql bellow just doesnt fit the things I wanted.
SELECT product_name, description FROM product WHERE description LIKE '%HP COMPUTERS%'
Is it necessary that i need to use
SELECT product_name, description FROM product WHERE description LIKE '%HP%' AND description LIKE '%COMPUTERS%' ..... ?
If I have 10 words, that means I will be having 10 likes..
Is there a simpler way of doing this ?
It will be great if I can make the search query case not sensitive.
That means even if i type Hp Computers it will still get the result although the field name contains "HP personal Computers.
I would like to make a search query to my database and return the search result if it mathes.
Currently it only returns the result when it matches the word "HP COMPUTERS" within the description.
What i want is it also returns the result if the field contains "HP personal COMPUTERS" or "COMPUTERS personal HP".
The sql bellow just doesnt fit the things I wanted.
SELECT product_name, description FROM product WHERE description LIKE '%HP COMPUTERS%'
Is it necessary that i need to use
SELECT product_name, description FROM product WHERE description LIKE '%HP%' AND description LIKE '%COMPUTERS%' ..... ?
If I have 10 words, that means I will be having 10 likes..
Is there a simpler way of doing this ?
It will be great if I can make the search query case not sensitive.
That means even if i type Hp Computers it will still get the result although the field name contains "HP personal Computers.