Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2005, 07:22 AM
Authorized User
 
Join Date: Jan 2004
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Ashleek007
Default counting fields in DB?!

hi,

Ive got a table with a number of records in :-

username | time
----------------------
ash | 0.01
ash | 0.04
ash | 1.12
lee | 0.23
lee | 2.34

I know how to count the number of records in the DB, but if you look at the table above there are two users that have records in this DB i want to know how i can count this, so the value now would be '2', but if another person was added to this table e.g:-

username | time
----------------------
ash | 0.01
ash | 0.04
ash | 1.12
lee | 0.23
lee | 2.34
dave | 0.43
lee | 4.32
ash | 0.12

i want that value to change to '3' as there are now 3 different people in the DB. The username field is unique meaning no two people can have the same.

Does anyone know how to do this? even if i jst get the method of SQL statement i could look it up

cheers
Ash:)

My new web design domain
www.askmultimedia.co.uk
__________________
My new web design domain
www.askmultimedia.co.uk
 
Old April 26th, 2005, 05:43 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

SELECT ~ GROUP BY username;
Suggestion: Use normaized tables, instead.

 
Old April 26th, 2005, 06:00 AM
DMK DMK is offline
Registered User
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is also possible.

Select Count(Distinct username) From <TableName>

Regards

DMK







Similar Threads
Thread Thread Starter Forum Replies Last Post
Global Search&Replace Text in all fields in sql db buddyz SQL Server 2000 10 September 14th, 2006 08:24 AM
problem in retreiving db fields in the text boxes umair_rathore Access ASP 1 February 17th, 2005 05:01 PM
Using Forum fields select fields on the fly hellosureshkumar Crystal Reports 0 December 17th, 2004 08:20 AM
Multiple db fields each with different conditions? sfinc Crystal Reports 1 February 27th, 2004 09:46 PM
Counting ?!? hcweb Classic ASP Basics 2 December 8th, 2003 05:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.