Mysql Connection_id Function

MySQL: CONNECTION_ID Function

This tutorial explains how to use the MySQL CONNECTION_ID function with syntax and examples.

Description

The MySQL CONNECTION_ID function returns the connection ID for the current connection, which is a unique ID among the currently connected clients.

Syntax

The syntax for the CONNECTION_ID function in MySQL is:

CONNECTION_ID( )

Parameters or Arguments

There are no parameters or arguments for the CONNECTION_ID function in MySQL.

Note

  • Each connection in the MySQL database has a connection ID that is unique among the currently connected clients.

Applies To

The CONNECTION_ID function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23.14

Example

Let's look at some MySQL CONNECTION_ID function examples and explore how to use the CONNECTION_ID function in MySQL.

For example:

mysql> SELECT CONNECTION_ID();

Since the CONNECTION_ID function returns the unique ID for the current connection, t might display something like this:

mysql> SELECT CONNECTION_ID();
Output: 57

In this case, the unique ID for the connection is 57.