Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

sqlite

hex

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.

like image 431
walterudoing Avatar asked Feb 07 '23 18:02

walterudoing


1 Answers

|| 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.

like image 101
Tim Biegeleisen Avatar answered Feb 19 '23 14:02

Tim Biegeleisen