简体   繁体   中英

Query for Product name search

Hi I have a Mysql Database which have product details in a table.I need to search product details by using a query.

Eg:When i type "Dosa" in the name search entry, it should be display "Dosa",Masala Dosa","Ghee Dosa" etc form product table.I used following query.But it is not usefull.

"SELECT productname FROM productmaster WHERE productname LIKE 'DOSA%' ORDER BY productname". It will list Dosa only.Kindly help in this regard.

You can just use a wildcard % on both sides of the search term:

SELECT productname
FROM productmaster
WHERE productname LIKE '%DOSA%'
ORDER BY productname
select * from productmaster where productname like '%DOSA%'
 $name = $_Post['name'];`

 $sql ="SELECT ID, DemoNeme1, DemoName2 FROM tableName WHERE  DemoNeme1 LIKE '%" . $name . "%' OR DemoName2  LIKE '%" . $name  ."%'";`

try this code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM