mysql搜索段名的表名 [英] mysql search for segment of table name

查看:121
本文介绍了mysql搜索段名的表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在一个mysql数据库中选择具有相同结尾的表,例如。 staff_name,manager_name,customer_name(example)。
我正在考虑沿着以下行的一些东西,因为如果我有一个确定的表名,它的工作。

  SELECT * FROM%_name; 

我也试过这个使用%而不是_没有运气。我不知道有没有其他通配符,我可以试试。我已经环顾四周,但没有一个结果似乎适用于表名的一部分:/任何建议?

解决方案

  SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME like'%_name'
and TABLE_SCHEMA ='your_db_name'



如果您要搜索当前数据库中的表,可以执行

  SHOW TABLES LIKE'%_name'


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 of the following because it works if I have a definite table name.

SELECT * FROM "%_name";

I also tried this using a % instead of the _ with no luck. I'm not sure if there are other wildcards I could try. I've looked around, but none of the results seem to apply to parts of table names :/ Any suggestions?

解决方案

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'

这篇关于mysql搜索段名的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆