Similar Products with bitwise I have the following tables.



So one product can have one category, one category can have n genres.(Products-> Genre Column data 6 ( 2 + 4), 132 (128 + 4) like that).

So my question is; i want to do find similar products for one product with using bitwise genres. Is that possible with sql query (or stored procedure)?

I never do something like that before, so i need help about it.

Thanks.
Yes, just use bitwise &amp; operator:

select products.genres, genre.Id from 
products inner join genre 
on products.genres &amp; genre.Id &gt; 0 
order by products.genres, genre.Id


SQL Fiddle