Search code examples
mysqloperatorsstatus

show status of multiple fields with LIKE and OR


I'm trying to show the status of two variables in mysql

$ sudo mysql -e "SHOW STATUS LIKE 'wsrep_local_state_comment' OR LIKE 'wsrep_cluster_size'"
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OR LIKE 'wsrep_cluster_size'' at line 1
$ sudo mysql -e "SHOW STATUS LIKE 'wsrep_local_state_comment' OR STATUS LIKE 'wsrep_cluster_size'"
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OR STATUS LIKE 'wsrep_cluster_size'' at line 1
$ sudo mysql -e "SHOW STATUS LIKE 'wsrep_local_state_comment' OR SHOW STATUS LIKE 'wsrep_cluster_size'"
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OR SHOW STATUS LIKE 'wsrep_cluster_size'' at line 1
$


Solution

  • You'll need to add WHERE

    SHOW STATUS WHERE variable_name IN ('x', 'y')
    

    or

    SHOW STATUS WHERE variable_name LIKE 'x' or variable_name LIKE 'y'