SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2000
    Location
    Eugene, OR
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I have a table which holds data about various books. I want to be able to select all of the authors from the table (last names are in one field and first names in another), and then print out a list of all the authors. I know how to just do this.

    However, many of the books have the same authors, and I don't want the list I print out to have more than 1 of each author listed. How do I do this? Is it possible to just select unique values? Moreover, I want last names that are the same to be selected as long as the first names are different, and vice-versa.

    Help Please

    Adam

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use DISTINCT
    SELECT DISTINCT Tb.Author from Tb

    SELECT Syntax: http://www.mysql.com/doc/S/E/SELECT.html
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, what you have here is a bit of a flaw in your database design - it sounds as if your author names are stored in the same table as your book titles/book information...bad idea!

    Here's something from WebmasterBase.com that explains this in detail: Relational Database Design.

    Good luck!


Bookmarks

Posting Permissions

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