I have a table having 10 columns, with id, f_name, l_name ..... low_range, high_range, ...
I want to write a query which will print all my table, but just this low_range and high_range to be converted in hex.
I know two things:
1. We can write all the column names and replacing the
low_range with hex(low_range) and high_range with high_range.
but 开发者_JAVA百科this asks me two to write all the column names, which seems a bit unfair.
2. We can write a query like:
select t.*, hex(low_range), hex(high_range) from table t
But it will give all the column names first and then the required fields in hex also after them, which I don't want to as there is a repetition of information.
Is there any other clean way to achieve this thing.
PS: I am new to databases.
In short, no. The two ways you list are the only two ways to specify column output order, so you can either:
select t.*
and then append your custom fields to the end (or the beginning) ORList each field individually eg
select t.field1, t.field2, hex(t.field3), t.field4...
The two methods you describe are the only ways to do this.
精彩评论