title: Best way to run Regular Expression search on full MySQL Table?
body: <p>I'm trying to find users that have setup more than one free account on my website. I need to search a table full of URLs using regex to find a certain ID within those URLs, then compare it to the users table.</p>
  
  <p><strong>For example, a row from the Users table looks like this:</strong></p>
  
  <p>USERID = 1
  ACCTYPE = 0
  UNAME = John</p>
  
  <p><strong>In the URLs table, the user stores a list of affiliate links.</strong></p>
  
  <p>USERID = 1
  URL = http:// example.com/?affid=1234</p>
  
  <p>USERID = 1
  URL = http:// example.com/cat3/?affid=1234</p>
  
  <p>USERID = 2
  URL = http:// example.com/cat3/?affid=5678</p>
  
  <p>USERID = 3
  URL = http:// example.com/cat6/?affid=1234</p>
  
  <p>Added spaces to urls for demo only.</p>
  
  <p><strong>I need to find any URLs with the same affid but different UserID.</strong></p>
  
  <p>As you can see in the example above, USERID 3 has the same affid as USER1.</p>
  
  <p>I'm not expecting anyone to write code for this, since I haven't provided a specific enough example. If someone could just explain the <em>theory</em> of how to do this, it would be very helpful.</p>
  
  <p>Thank you in advance.</p>