Skip to content
Advertisement

SELECT hex(name || age) AS X FROM Ages ORDER BY X

I am taking a Cousera course talking about SQL and there is one line of code I cannot understand.

What does it mean by ‘hex(name || age)’? I know it turns the string into hexadecimal format using the hex() function, but what does ‘name || age’ do? I cannot find any document about the ‘||’ operator.

Advertisement

Answer

|| is the SQLite concatenation operator. So hex(name || age) will pass a concatenated string of name and age into the hex() function.

From the SQLite documentation:

The hex() function interprets its argument as a BLOB and returns a string which is the upper-case hexadecimal rendering of the content of that blob.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement