Results 1 to 6 of 6

Thread: Distinct rows but all columns?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    5

    Distinct rows but all columns?

    Is there a way to make a SQL statement that will only return distinct rows but ALL columns?
    I have a table somehow like this:

    ORDER CUSTOMER ORDER DATE
    1 1010 05/04/2005
    1 1010 05/04/2005
    2 1011 05/09/2005
    3 1010 05/10/2005

    I want to filter maybe by order number and put the results in a listview control like this:

    ORDER CUSTOMER ORDER DATE
    1 1010 05/04/2005
    2 1011 05/09/2005
    3 1010 05/10/2005

    I guess I'm thinking of a query like:
    "SELECT ALL customer, orderdate DISTINCT order FROM table..." but this of course is wrong. Any help will be appreciated.

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Distinct rows but all columns?

    I think the query should go along the lines of...

    "SELECT customer, orderdate DISTINCT order FROM table..."

    That should select them all if I am correct

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    5

    Re: Distinct rows but all columns?

    Thanks for your quick response but it doesn't work, gives me the error message:

    runtime error '3075'

    Syntax error (missing operator) in query expression ...

    Any other idea?

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Distinct rows but all columns?

    Quote Originally Posted by chiefo
    Thanks for your quick response but it doesn't work, gives me the error message:

    runtime error '3075'

    Syntax error (missing operator) in query expression ...

    Any other idea?

    In that case I ahve no idea, but the MySQL Manual may help you


    Cheers and sorry I could be of no more help

    RyanJ
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    5

    Re: Distinct rows but all columns?

    Thanks for your interest Ryan, cheers.

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Distinct rows but all columns?

    You need to place the distinc after select like this:
    Code:
    SELECT DISTINCT `customer`, `orderdate` `order` FROM table;
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width