EchoFool Posted April 12, 2010 Share Posted April 12, 2010 Hey im not entirely sure what kind of query im looking for with this... But i have a table with ips linked with userid ... so 1 userid could have many ips obviously. Now say id 1 and id 2 want to make a transaction i want to prevent it by checking this ip table to see if they have ever had an ip that was the same.... =/ Any ideas what kind of query im looking for mainly related to the WHERE clause ? Quote Link to comment https://forums.phpfreaks.com/topic/198286-table-check-for-ip-matches/ Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 SELECT COUNT(*) c FROM ip_table i1 INNER JOIN ip_table i2 ON i1.ip = i2.ip LIMIT 1 Not tested, but even if it doesn't work, does it give you an idea how this would be handled? Quote Link to comment https://forums.phpfreaks.com/topic/198286-table-check-for-ip-matches/#findComment-1040424 Share on other sites More sharing options...
EchoFool Posted April 12, 2010 Author Share Posted April 12, 2010 umm i dont understand the COUNT(*) c then the i1 and i2 ? What are they? Quote Link to comment https://forums.phpfreaks.com/topic/198286-table-check-for-ip-matches/#findComment-1040490 Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 They are aliases. Quote Link to comment https://forums.phpfreaks.com/topic/198286-table-check-for-ip-matches/#findComment-1040491 Share on other sites More sharing options...
EchoFool Posted April 12, 2010 Author Share Posted April 12, 2010 They are confusing me as to which are aliases and which are fields in your example :S Quote Link to comment https://forums.phpfreaks.com/topic/198286-table-check-for-ip-matches/#findComment-1040498 Share on other sites More sharing options...
EchoFool Posted April 12, 2010 Author Share Posted April 12, 2010 Would this be correct? SELECT IP FROM iplogs t1 INNER JOIN iplogs t2 ON t1.IP = t2.IP WHERE t1.userID='$UserID1' AND t2.UserID='$UserID2' LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/198286-table-check-for-ip-matches/#findComment-1040507 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.