Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

select vs desc

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys

i want to know when execuite a query like "desc TableName"
it will return a column name and the column datatype in the order they where
in the table even though you execuite different times you will get same order

but if we execuite a query like "select * from TableName"
it will return resultset of different order at different times

in both the query we are not using any order by statement
i want to know what makes desc statement resultset consistenet

regards
amir
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amirtharaj Chinnaraj:
hi guys

i want to know when execuite a query like "desc TableName"
it will return a column name and the column datatype in the order they where
in the table even though you execuite different times you will get same order

but if we execuite a query like "select * from TableName"
it will return resultset of different order at different times

in both the query we are not using any order by statement
i want to know what makes desc statement resultset consistenet

regards
amir



You are confusing the describe a table (DESC TableName) statement with the descending key word used in an order by clause. You will get the same result if you execute DESCRIBE TableName as you do with Desc TableName. Its purpose is to give you information about your table's make-up... it isn't intended to provide a result set.
[ October 24, 2007: Message edited by: Paul Campbell ]
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well paul

let me expalin my doubt clearly ,iam using mysql database i use jdbc to
connect with database

when i execute a select query without order by statement i get different ordered resultset at different times

but when i execute a describe query i get the resultset with the same order for n number times what makes desc to be consistent

if i want to oder the resultset of a describe query how can i do it for mysql

regards
amir
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't order the information returned from a describe table statement.
The statement/command is for providing information about the columns of the table. It shows the column names, the type / size and scale (if applicable) and other useful information.

DESCRIBE table_name

However, you can do describe output select * from table_name ordered by...
[ October 25, 2007: Message edited by: Paul Campbell ]
reply
    Bookmark Topic Watch Topic
  • New Topic