CONNECTION_ID() returns the current connection ID
mysql> mysql> mysql> SELECT CONNECTION_ID(); +-----------------+ | CONNECTION_ID() | +-----------------+ | 147 | +-----------------+ 1 row in set (0.00 sec) mysql>