[Solved] sql search in multi columns [closed]


Put parens around your or-ed conditions, and change the double quotes to single quotes for the year (as suggested by jarlh):

select from products 
WHERE year="2016" 
and (
    name like '%"& name &"%' 
    or size like '%"& Size &"%'
)

Oh and in case this is VB.NET and you got name and Size from a parameter or something, make sure you are escaping them to prevent SQL injection (if this not already done somewhere else).

1

solved sql search in multi columns [closed]