0
SELECT ord
     , custname
     , custnumber
     , city 
  FROM ord 
 WHERE custnumber IN ( SELECT custnumber 
                         FROM ord 
                        GROUP 
                           BY custname
                            , custnumber
                            , city 
                       HAVING COUNT(custnumber) > 1 ) 
 ORDER 
    BY custnumber DESC

And I got this

#2013 - Lost connection to MySQL server during query

enter image description here

Any solutions?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Perhaps try using a JOIN instead – Strawberry Oct 21 '20 at 11:16
  • 2
    Does this answer your question? [MySQL "IN" operator performance on (large?) number of values](https://stackoverflow.com/questions/4514697/mysql-in-operator-performance-on-large-number-of-values) – P.Salmon Oct 21 '20 at 12:02
  • I tried and I used JOIN " select t1.`CUSTNAME`,t1.`CUSTNUMBER`,t1.`CITY` from ORD t1 join ( select `CUSTNUMBER` from ORD group by `CUSTNAME`, `CUSTNUMBER`, `CITY` having count(*) >= 3 ) t2 on t1.`CUSTNUMBER` = t2.`CUSTNUMBER` ORDER BY `CUSTNUMBER` desc" – Abdirahman Mohamud Abdullahi Oct 24 '20 at 08:16

1 Answers1

0

I tried and I got a solution. I used this query "

select t1.CUSTNAME,t1.CUSTNUMBER,t1.CITY from ORD t1 join ( select CUSTNUMBER from ORD group by CUSTNAME, CUSTNUMBER, CITY having count(*) >= 3 ) t2 on t1.CUSTNUMBER = t2.CUSTNUMBER ORDER BY CUSTNUMBER desc"

I used Join instead of IN.