22

It is an easy task to find MySQL variable values:

mysql> show variables where Variable_name = 'version';
+---------------+--------------------+
| Variable_name | Value              |
+---------------+--------------------+
| version       | 5.0.19-Max         |
+---------------+--------------------+
1 row in set (0.00 sec)

But is there any syntax that allows to select only column with variable value, like so:

mysql> command_i_want_to_know
+--------------------+
| Value              |
+--------------------+
| 5.0.19-Max         |
+--------------------+
1 row in set (0.00 sec)

3 Answers 3

35

One more variant -

SELECT @@version;
Sign up to request clarification or add additional context in comments.

Comments

10
select variable_value 
from information_schema.global_variables
where variable_name = 'version';

2 Comments

As written in the manual "The GLOBAL_VARIABLES and SESSION_VARIABLES tables were added in MySQL 5.1.12." So this does not work in 5.0 dev.mysql.com/doc/refman/5.1/en/variables-table.html
That's the way for 5.5 users, BTW my problem solved by @Devart.
0

Complementing previous answers: depending on your MySQL version and settings, you will probably need this to make it work:

set @@global.show_compatibility_56=1;

You may also want to add this to your my.cnf, under the [mysqld] section:

show_compatibility_56 = 1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.