thecard Posted June 6, 2008 Share Posted June 6, 2008 I have 2 queries, I wrote one of them, and found the other on the internet as I find it preety confusing! I need to make them cause and effect: The first: $dothis = mysql_query("SELECT * FROM tb_users tb WHERE EXISTS(SELECT tb2.ip FROM tb_users tb2 WHERE tb.ip=tb2.ip AND tb.username<>tb2.username) order by ip") or die (mysql_error()); The second: $thisagain= mysql_query("UPDATE tb_users SET suspen='logged'") or die (mysql_error()); So basically if there is a duplicated ip of a users, I need all their account's "suspens" to be logged. Sorry, I'm a bit of a noob. I've tried changing select to UPDATE and loads of other stuff. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 7, 2008 Share Posted June 7, 2008 I'm very confused... you want to run the update for only the matching users from the select? Your current update has no where clause!` Quote Link to comment Share on other sites More sharing options...
thecard Posted June 7, 2008 Author Share Posted June 7, 2008 I want to do this with a mysql query: Search for users who have the same ip address. Update these user's accounts. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 10, 2008 Share Posted June 10, 2008 Did you try (UNTESTED): UPDATE tb_users tb WHERE EXISTS(SELECT tb2.ip FROM tb_users tb2 WHERE tb.ip=tb2.ip AND tb.username<>tb2.username) SET tb.suspen='logged' Quote Link to comment 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.