SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    UK
    Posts
    539
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Distinct problem

    I have:

    $qry="SELECT DISTINCT(city) FROM table WHERE country='$country'";

    If there are no rows with a 'city' where country=$country, it still gives 1 row result of NULL!
    Why does it return a blank row rather than no rows?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    DISTINCT is not a function, don't put () around the column name.

    If you get a row with value NULL returned, then apparently there is a row in the database where country=$country and city=NULL.


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
  •