mysql search for segment of table name

后端 未结 2 613
囚心锁ツ
囚心锁ツ 2021-02-01 07:30

I\'m trying to select tables in a mysql database which have the same ending, e.g. staff_name, manager_name, customer_name (example). I was thinking of something along the lines

相关标签:
2条回答
  • 2021-02-01 08:00
    SELECT TABLE_NAME 
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_NAME like '%_name'
    and TABLE_SCHEMA = 'your_db_name'
    

    If you want to search for tables in your current DB you can do

    SHOW TABLES LIKE '%_name'
    
    0 讨论(0)
  • 2021-02-01 08:19

    you can do in 3 way

    show tables like '%yourtablename'
    show tables like '%yourtablename%'
    
    show tables like 'yourtablename%'
    
    0 讨论(0)
提交回复
热议问题