Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL select selected columns plus all other columns on command line

Tags:

mysql

It used to be that I could fire a query like the following in a query window/sql command line, against MS SQL server:

SELECT foo1, foo2, * from bar

Basically show the specified columns followed by rest of the columns. But MySQL does not allow this; throws back a syntax error at me. Is there an alternative syntax to do this in MySQL? Note that I am NOT trying to do this in code (where it has no practical use); I am using it for firing random queries against my DB to look up information.

like image 988
Amit Avatar asked Sep 06 '25 20:09

Amit


1 Answers

Just declare the table on the SELECT CLAUSE.

SELECT foo1, foo2, bar.* from bar;

OR

SELECT b.foo1, b.foo2, b.* from bar b;

;-)

like image 123
medina Avatar answered Sep 09 '25 06:09

medina