So it's just a simple question I have this query. It's not working so I just thought I'd make sure that this isn't possible.
SELECT * FROM warehouse WHERE sku LIKE IN ($clean) AND style= :style9 ORDER BY sku ASC
So it's just a simple question I have this query. It's not working so I just thought I'd make sure that this isn't possible.
SELECT * FROM warehouse WHERE sku LIKE IN ($clean) AND style= :style9 ORDER BY sku ASC
I don't recognize LIKE IN as a thing.
You might try sku LIKE '%' + ($clean) + '%'
Or, if you're looking for it the other way around: ($clean) LIKE '%' + sku + '%'
Is there a combination of "LIKE" and "IN" in SQL? Here is a discussion of using Contains, if you would like to try using that.
 
    
     
    
    There is no combination of LIKE & IN in SQL,so you have to use sql like
SELECT * FROM warehouse WHERE sku LIKE '%$clean%' AND style= :style9 ORDER BY sku ASC
 
    
    Like and In both are different thing, you can easily understand from the below snippet of code, hopefully this will help you to remove your confusion :)
select 
    *
from
    emp
where
    name like @param +'%'
Select
   *
from
   emp where name in ('abc', 'xyz')  
 
    
    Not knowing what your $clean value looks like (or your sku values or expected results) I can only guess, but REGEXP, also known as RLIKE, might be useful here.
Say you're looking for SKU's like 'AB%', 'XY%', and 'FG%'. You can do that with RLIKE as follows:
SELECT * FROM warehouse WHERE sku RLIKE '^(AB|XY|FG)' AND ...
 
    
    You could use REGEXP to achieve what your trying to achieve, so you query will look like
SELECT * 
FROM warehouse 
WHERE sku REGEXP REPLACE($clean,',','|') AND style= :style9 
ORDER BY sku ASC
Going on the assumption that $clean is comma delimited list of values.
