SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    selecting distinct

    I have a table that is set up like:

    Code:
    id | artist | song | album
    Where there could be multiple entries that had the same artist and song. I want to select distinct how that if there are rows which the artist and song are the same as other rows, I only get one occurrence returned. So, something that would look like this (but obviously this doesn't work):

    PHP Code:
    $sql->query("SELECT DISTINCT(artist, song) AS title FROM lifethemesong LIMIT $x"); 
    Is there anyway to do this?
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  2. #2
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DISTINCT is an option, not a function.

    Code MySQL:
    SELECT DISTINCT CONCAT(artist, ' - ', song) AS title
      FROM lifethemesong
     LIMIT $x

    Also, LIMIT doesn't make much sense without order specified.


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
  •