Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-08-2013, 11:49 AM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,513
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
How do I count Uniques in mySQL ??

Hi,

A table which consists of lines with several entries for the same client
and I want to count how many different clients there are.

So I need to count only the number of uniques.

This is what I have:

PHP Code:
$sql_cnt "SELECT item_id FROM main WHERE platform_no = '$platform_id' AND plat_type = '$Db_type'";

$result_cnt mysql_query($sql_cnt)    or die("could not count the ITEMS"mysql_error() );  

$num_cnt mysql_num_rows($result_cnt); 
I NEED TO ADD SOMETHİNG LİKE :


PHP Code:
$sql_cnt "SELECT item_id FROM main WHERE platform_no = '$platform_id' AND plat_type = '$Db_type AND client_no IS UNIQUE'";

$result_cnt mysql_query($sql_cnt)    or die("could not count the ITEMS"mysql_error() );  

$num_cnt mysql_num_rows($result_cnt); 

Does anyone know what the proper syntax is for this query ?

thanks.


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-08-2013, 12:29 PM   PM User | #2
Thyrosis
New Coder

 
Join Date: Nov 2012
Posts: 72
Thanks: 4
Thanked 11 Times in 11 Posts
Thyrosis is on a distinguished road
Something like this should do the trick I guess.

PHP Code:
$sql_cnt 
"SELECT client_no
FROM main
WHERE platform_no = '$platform_id'
AND plat_type '$Db_type'
GROUP BY client_no"


Last edited by Thyrosis; 01-08-2013 at 12:30 PM.. Reason: changed select value
Thyrosis is offline   Reply With Quote
Old 01-11-2013, 04:20 PM   PM User | #3
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,513
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Thank you-

I will give that a try
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-11-2013, 04:53 PM   PM User | #4
hinch
Regular Coder

 
hinch's Avatar
 
Join Date: Sep 2005
Location: UK
Posts: 921
Thanks: 25
Thanked 79 Times in 79 Posts
hinch is on a distinguished road
PHP Code:
$sql_cnt "SELECT DISTINCT item_id FROM main WHERE platform_no = '$platform_id' AND plat_type = '$Db_type'";

$result_cnt mysql_query($sql_cnt)    or die("could not count the ITEMS"mysql_error() );  

$num_cnt mysql_num_rows($result_cnt); 
__________________
A programmer is just a tool which converts caffeine into code

My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
My hobby: http://www.angel-computers.co.uk
My life: http://www.furious-angels.com
hinch is offline   Reply With Quote
Old 01-16-2013, 08:00 AM   PM User | #5
ahamadhussain
New to the CF scene

 
Join Date: Jan 2013
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
ahamadhussain is an unknown quantity at this point
Hai Buddies....
Already I have facing same problem select the unique name...so, this code also worked properly...
$sql_cnt = "SELECT DISTINCT item_id FROM main WHERE platform_no = '$platform_id' AND plat_type = '$Db_type'";

$result_cnt = mysql_query($sql_cnt) or die("could not count the ITEMS". mysql_error() );

$num_cnt = mysql_num_rows($result_cnt);
ahamadhussain is offline   Reply With Quote
Old 01-16-2013, 08:04 AM   PM User | #6
ahamadhussain
New to the CF scene

 
Join Date: Jan 2013
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
ahamadhussain is an unknown quantity at this point
Hai Buddies...
Already i have facing the same problem. select the unique thing from database
I also worked the following query...
$sql_cnt = "SELECT DISTINCT item_id FROM main WHERE platform_no = '$platform_id' AND plat_type = '$Db_type'"; \\Used DISTINCT

$result_cnt = mysql_query($sql_cnt) or die("could not count the ITEMS". mysql_error() );

$num_cnt = mysql_num_rows($result_cnt);
ahamadhussain is offline   Reply With Quote
Old 01-16-2013, 08:58 AM   PM User | #7
tinaliy
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tinaliy is an unknown quantity at this point
I will help you to check it too.
tinaliy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:09 AM.


Advertisement
Log in to turn off these ads.