Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/66639-how-would-i-count-this/
Share on other sites

 

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).

 

 

@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  ;D

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 :P

 

Oh,

 

And I'm still hoping someone can help...

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;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.