mysql_thread_id() returns the thread ID of the current connection.
Syntax
unsigned long
mysql_thread_id(MYSQL *mysql)
Return values
The thread ID of the current connection.
Error messages
None.
Notes
The value of thread ID can be used as the argument of mysql_kill() to terminate the thread.
If the connection is lost and then re-established by calling mysql_ping(), the thread ID changes. Therefore, we recommend that you do not store the obtained thread ID for later use.
If the thread ID is greater than 32 bits, this function cannot work properly. To avoid errors for mysql_thread_id(), you can execute the SELECT CONNECTION_ID() query, retrieve the results, and get the connection ID.