|
-
May 26th, 2005, 02:15 PM
#1
Thread Starter
New Member
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.
-
May 26th, 2005, 02:19 PM
#2
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
-
May 26th, 2005, 02:31 PM
#3
Thread Starter
New Member
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?
-
May 26th, 2005, 02:33 PM
#4
Re: Distinct rows but all columns?
 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
-
May 26th, 2005, 02:38 PM
#5
Thread Starter
New Member
Re: Distinct rows but all columns?
Thanks for your interest Ryan, cheers.
-
May 26th, 2005, 02:51 PM
#6
Re: Distinct rows but all columns?
You need to place the distinc after select like this:
Code:
SELECT DISTINCT `customer`, `orderdate` `order` FROM table;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|