Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Count question

  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Count question

    Hi there.

    I am new to these forums and would be very grateful for any assistance with the following issue i have.

    I have a table, in one column lists people's first names. I need to create a bit of php code which will count how many people have the same first name.

    The trouble is, because any first name can be present in the database column i dont know how to count if there are any repeats.

    Can want i am wanting to achieve be done?

    thanks for any help.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    Code:
    SELECT `name_column_name`, COUNT(`name_column_name`) as `total` FROM `user_table_name` GROUP BY `name_column_name`
    Use that SQL, replacing the values with yours (ie name_column_name and user_table_name)
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • Users who have thanked JAY6390 for this post:

    D3monite (01-19-2010)

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    worked a charm. thank you!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •