使用LIKE检索行并传递一些id。

I want to retrieve a row with keyword "off" and sc_id must be equal to "2". I am trying following query but it gives me the rows with keyword "Off" and also gives all the sc_id's. How to solve this. The id search is the must part.

Query

SELECT c.* , sc.* , sm.* ,ca.* 
from store_category sc 
INNER JOIN store_manufacture sm 
   ON sm.sm_id=sc.store_id 
INNER JOIN categories ca 
   ON ca.cat_id=sc.cat_id 
INNER JOIN coupons c 
   on c.c_sc_id=sc.sc_id 
WHERE sc.sc_id=2 
  AND c.c_name LIKE '%off%' 
   OR sm.sm_brand_name LIKE '%off%' 
   OR ca.cat_name LIKE '%off%' 
   OR c.c_description LIKE '%off%'

You need to use parenthesis for your conditions, try this:

SELECT c.* , sc.* , sm.* ,ca.* 
from store_category sc 
INNER JOIN store_manufacture sm 
ON sm.sm_id=sc.store_id 
INNER JOIN categories ca 
ON ca.cat_id=sc.cat_id 
INNER JOIN coupons c 
ON c.c_sc_id=sc.sc_id 
WHERE sc.sc_id=2 
AND (c.c_name LIKE '%off%' 
OR sm.sm_brand_name LIKE '%off%' 
OR ca.cat_name LIKE '%off%' 
OR c.c_description LIKE '%off%');