2

I have a primary kew which is a binary(16) UUID in a field called binid.
I would like to get ALL columns including the binary id with a SELECT statement.

I know I can do "SELECT * FROM TABLE", but how to combine with HEX(binid)?

This works when I get individual fields: "SELECT HEX(binid) AS binid FROM TABLE"
but I dont want to mention all of the fields (too many). Is there a way to get ALL and HEX in one statement?

PS. I am creating based on stackoverflow question: How to store uuid as number?

Community
  • 1
  • 1

3 Answers3

1

Selecting * will select all the fields as they are, without transformations. To select them changing their formats you will have to specify all the fields you want to select spearated by ,.

For instance:

SELECT HEX(`binid`) as `bindid`, `name`, FROM_UNIXTIME(`birthday`) as `birthday`, `gender` FROM `table`;

You can apply as many transformations you want.

You can also do this:

SELECT HEX(`binid`) as `hexdid`, * FROM `table`;

In this case the result will have both the binid in hex format, named hexid, and also the original binid aswell with the other fields of the table.

Havenard
  • 27,022
  • 5
  • 36
  • 62
0
select col1, col2, col3 from table

e.g. if table is called T and set as thus:

        T
=================
| binid | A | B |
| 0     | 1 | a |
| 1     | 2 | b |
| 10    | 3 | c |

select hex(binid), A, B from table
boisvert
  • 3,679
  • 2
  • 27
  • 53
0

You could do:

Select *, HEX(binid) as clearBinId from Table

This will select all the columns (including binid) and also select the HEX(binid) as a column called 'clearBinId'

Niro
  • 776
  • 8
  • 15