I have 2 tables in my database. One is for orders, and one is for companies.
Orders has this structure:
OrderID | attachedCompanyIDs
-------
Let me explain when to use FIND_IN_SET and When to use IN.
Let's take table A which has columns named "aid","aname". Let's take table B which has columns named "bid","bname","aids".
Now there are dummy values in Table A and Table B as below.
aid aname
1 Apple
2 Banana
3 Mango
bid bname aids
1 Apple 1,2
2 Banana 2,1
3 Mango 3,1,2
enter code here
Case1: if you want to get those records from table b which has 1 value present in aids columns then you have to use FIND_IN_SET.
Query: select * from A JOIN B ON FIND_IN_SET(A.aid,b.aids) where A.aid = 1 ;
Case2: if you want to get those records from table a which has 1 OR 2 OR 3 value present in aid columns then you have to use IN.
Query: select * from A JOIN B ON A.aid IN (b.aids);
Now here upto you that what you needs through mysql query.