Best way to run Regular Expression search on full MySQL Table?
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.
For example, a row from the Users table looks like this:
USERID = 1 ACCTYPE = 0 UNAME = John
In the URLs table, the user stores a list of affiliate links.
USERID = 1 URL = http:// example.com/?affid=1234
USERID = 1 URL = http:// example.com/cat3/?affid=1234
USERID = 2 URL = http:// example.com/cat3/?affid=5678
USERID = 3 URL = http:// example.com/cat6/?affid=1234
Added spaces to urls for demo only.
I need to find any URLs with the same affid but different UserID.
As you can see in the example above, USERID 3 has the same affid as USER1.
I'm not expecting anyone to write code for this, since I haven't provided a specific enough example. If someon开发者_如何学Pythone could just explain the theory of how to do this, it would be very helpful.
Thank you in advance.
You could probably do a JOIN with the same table, but to make it efficient I would extract the affiliate id out of the URL at insert time, into its own column. That way your query would not require regular expression (LIKE) at all.
精彩评论