locked
SQL Query to find all table names on a database with MySQL RRS feed

  • Question

  • User-1453200658 posted

    These are tables list on database MySql version 8.0.17

        t_contents_s300_10_2021
        t_contents_s300_1_2021
        t_contents_s300_2_2021
        t_contents_s300_3_2021
        t_contents_s34d_1_2021
        t_contents_s34g_1_2021
        t_contents_s34g_2_2021
        t_contents_s3sv_1_2021
        t_contents_s3sv_2_2021

    I need find on these list of tables all table like `s3` and `1` and `2021`

    I have tried this query but the return contains all numbers and not only `1`

    How to do resolve this?

    Thanks in advance for any help.

        mysql> SELECT
            table_name 
        FROM
            information_schema.TABLES 
        WHERE
            table_name LIKE ( 't_contents_s3%' );
        +-------------------------+
        | TABLE_NAME              |
        +-------------------------+
        | t_contents_s300_10_2021 |
        | t_contents_s300_1_2021  |
        | t_contents_s300_2_2021  |
        | t_contents_s300_3_2021  |
        | t_contents_s34d_1_2021  |
        | t_contents_s34g_1_2021  |
        | t_contents_s34g_2_2021  |
        | t_contents_s3sv_1_2021  |
        | t_contents_s3sv_2_2021  |
        +-------------------------+
        9 rows in set (0.44 sec)
    Wednesday, February 17, 2021 6:11 PM

Answers

  • User269602965 posted

    SELECT
            table_name 
        FROM
            information_schema.TABLES      WHERE         table_name LIKE ( 't_contents_s3%1_2021' );

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 18, 2021 1:37 AM