MySQL | CONNECTION_ID( ) Function

The MySQL CONNECTION_ID() function is used for return the connection ID for a current connection in MySQL. The connection ID used to establish a connection to a database is unique for every connection among the connected clients. The CONNECTION_ID() function does not require any parameters or arguments.

The value returned by the CONNECTION_ID() function is the same type of value as displayed in the ID column of the INFORMATION_SCHEMA.PROCESSLIST table.

Syntax:

CONNECTION_ID()

Parameters Used:
The CONNECTION_ID() function does not require any parameters or arguments.

Return Value:
The MySQL CONNECTION_ID() function returns an integer value which represents the unique current connection ID.



Supported 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

Example: Implementing CONNECTION_ID() function.

SELECT CONNECTION_ID(); 

Output:

1196078 
My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.