» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 02-02-2007, 04:46 AM
Crilon Crilon is offline
Junior Member
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Crilon is on a distinguished road
Default DISTINCT/SELECT statement?

Hello all of you,
I am wondering what's the order when "DISTINCT" is used in SELECT statement? i.e. choosing "SELECT DISTINCT * from table_name", the
output is sorted with what order? How about if add distinct "ORDER BY"?
thanks for any input. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 02-02-2007, 07:45 AM
domin domin is offline
Senior Member
 
Join Date: Jul 2006
Posts: 167
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 18
domin is on a distinguished road
Default

To get output in a particular order, use ORDER BY. It will always take precedence. Without ORDER BY, data is not necessarily returned in any particular order, but DISTINCT is processed similar to GROUP BY, and GROUP BY necessarily has to order the data in order to group it, so it will have an effect on the order in the absence of ORDER BY. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Performing multi-line SQL statement Cigma MySQL Forums 1 02-07-2007 08:03 AM
writing a single statement? Bobb MySQL Forums 1 12-23-2006 04:51 AM
Where Statement? sugreeh MySQL Forums 1 11-03-2006 04:54 AM
Error in select statement speedy PHP Programming and Tips 1 08-19-2006 10:32 AM
sql statement for asp page dutchman ASP forums and Tips 1 08-08-2006 03:02 PM


All times are GMT. The time now is 12:24 AM.