FIND_IN_SET() vs IN()

前端 未结 6 778
滥情空心
滥情空心 2020-11-22 06:20

I have 2 tables in my database. One is for orders, and one is for companies.

Orders has this structure:

OrderID     |     attachedCompanyIDs
-------         


        
6条回答
  •  囚心锁ツ
    2020-11-22 07:04

    because the second query is looking for rows with the id's 1 OR 2 OR 3, the first query is looking for a one of the comma delimited values to exist in companyID,

    and another problem here is you aren't joining the tables on a common key in your where so you are going to get a mutation of rows that = count(table1) * count(table2);

    Your problem really exists with part 2 of my answer. (with your second query)

提交回复
热议问题