AV1611 Posted August 25, 2007 Share Posted August 25, 2007 I need to know how many rows this will return, not the actual data. SELECT DISTINCT a.name,a.ip,b.name FROM onlineip AS a Inner Join onlineip AS b ON a.ip = b.ip WHERE a.name NOT LIKE b.name AND a.ip NOT LIKE '' AND a.name NOT LIKE 'Recruit' AND b.name NOT LIKE 'Recruit' order by a.name I can't figure out how to do this in sql I am going to use it in PHP , but I need to know the answer before I run the query. I don't want to run the same query twice because that would be retarded Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 25, 2007 Share Posted August 25, 2007 The manual is a great resource: http://dev.mysql.com/doc/refman/4.1/en/group-by-functions.html#function_count Quote Link to comment Share on other sites More sharing options...
AV1611 Posted August 25, 2007 Author Share Posted August 25, 2007 The manual is a great resource: http://dev.mysql.com/doc/refman/4.1/en/group-by-functions.html#function_count Don't be a punk... This is a help forum. If you don't like the question, don't answer. I already know where the manual is, and was just being lazy (as most posters are... we're all human). I decided to solve this with PHP (and did), but I still would like to know how to do this with the group by function your link alludes to, but I couldn't figure out (hence the validity of my question and the stupidity of your answer). Quote Link to comment Share on other sites More sharing options...
Fadion Posted August 25, 2007 Share Posted August 25, 2007 @AV1611 someone whos trying to help is not a punk neither his/her answers are stupid. Being helped should be considered a privilege, even if the answer is not what u really wanted. Anyway dont know about your question, but the last part of your signature is pretty cool Quote Link to comment Share on other sites More sharing options...
AV1611 Posted August 26, 2007 Author Share Posted August 26, 2007 Perhaps I was a bit grouchy, but his answer was meant to ridicule more than to help. I have help quite a few people here over the years myself. I may not know as much as some, but I've been a help to many. I just get tired of the smugness. ADMIN if you like, you can delete this thread, as you know this is not how my threads usually end up Oh, And I'm still hoping someone can help... Quote Link to comment Share on other sites More sharing options...
Barand Posted August 26, 2007 Share Posted August 26, 2007 I think you need <?php $sql = "SELECT COUNT(DISTINCT CONCAT(a.name,a.ip,b.name)) as recs FROM onlineip AS a Inner Join onlineip AS b ON a.ip = b.ip WHERE a.name NOT LIKE b.name AND a.ip NOT LIKE '' AND a.name NOT LIKE 'Recruit' AND b.name NOT LIKE 'Recruit' ORDER BY a.name"; $res = mysql_query($sql); $count = mysql_result($res,0); echo $count; Quote Link to comment Share on other sites More sharing options...
AV1611 Posted August 26, 2007 Author Share Posted August 26, 2007 I'll let you know how that works out Barand, you are once again my hero 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.