tags:

views:

37

answers:

3

I have a table structure like :

ID, Test_ID, Verdict, PATH, Last_Status, 
Present_status, Remote_location,TestCase

I want the result to be displayed starting with TestCase But I do not want to mention all the fileds particularly. Is there anything like

select TestCase,* from Table order by TestCase` ? 

Basically the result should be displayed as

Testcase, ID, Test_ID, Verdictm PATH,
Last_Status, Present_statusmRemote_location

If I try the above select, it does not work in MYSQL. Is there any command to achive what I require?

Thanks.

+2  A: 

you have to list all the fields you want in the order you want them in. it is either use * or list what you want, and just for the future using * is bad practice.

fuzzy lollipop
+3  A: 

Not that I know of. Even so, it's good practice to avoid using SELECT * FROM tableName wherever possible.

If your column list ever changes, queries in your code may assign values to the wrong fields.

Tenner
+1  A: 

yes, just list the columns you want first explicitly in the Select clause:

Select Testcase, t.* From TableName

But the asterisk will cause the testcase column to be output no matter what, so you will get it twice. To avoid ambiguous redundant column names, you will have to alias the first one:

Select Testcase as FirsttestCase, t.* From TableName
Charles Bretana
I guess there is no point in displaying the same field twice to the user which will annoy him.
JPro
Then I suugest you explicitly list all the columns in your Select clause, in the order you prefer them.
Charles Bretana
this is bad advice to use the * for pretty much anything except ad hoc queries for debugging
fuzzy lollipop
@fuzzy, read the question before you criticize the answer...
Charles Bretana