0

I am working on a mysql database and I am trying to select and not use emails that are @gmail or @yahoo and stuff. I am using the following select

select 1stBusPocEmail
     , PhysicalAddressZipPostalCode  
  from contractors 
 where 1stBusPocEmail NOT like '%aol.com' 
    or 1stBusPocEmail NOT like '%AOL.COM' 
    or 1stBusPocEmail NOT like '%bellsouth.net' 
    or 1stBusPocEmail NOT like '%GMAIL.COM' 
    or 1stBusPocEmail NOT like '%yahoo.com' 
    or 1stBusPocEmail NOT like '%gmail.com' 
    or 1stBusPocEmail NOT like '%hotmail.com' 
    or 1stBusPocEmail NOT like '%.gov' 
   and PhysicalAddressZipPostalCode like '327%' 
    or PhysicalAddressZipPostalCode like '328%' 
   and BusinessTypeString NOT LIKE '%A2%' 
   and BusinessTypeString NOT LIKE '%A5%' 
   and BusinessTypeString NOT LIKE '%OY%' 
   and BusinessTypeString NOT LIKE '%QF%'  
 order 
    by rand() 
 limit 50 ; 

I do this and it works pretty well but a few gmails are still getting through. here is a sample output

 +---------------------------------+------------------------------+
| 1stBusPocEmail                  | PhysicalAddressZipPostalCode |
+---------------------------------+------------------------------+
| sholomt@gmail.com               | 60030                        |
| shaynes@briggs.k12.ok.us        | 74464                        |
| alon@seamedive.net              | 33317                        |
| jmurray@foxsubacute.com         | 17055                        |
| msmith@g2klabs.com              | 20151                        |
| vk@vektroncorp.com              | 18966                        |
| lberczel@heritage-collision.com | 48197                        |
| christy.brudin@gmail.com        | 22043                        |
| gjesclard@hotmail.com           | 99516                        |
| lee.fuller@fullerlabs.net       | 92831                        |
  +---------------------------------+------------------------------+
10 rows in set (7.67 sec)
Barmar
  • 741,623
  • 53
  • 500
  • 612

0 Answers0