?
Solved

filter out mySQL table name

Posted on 2014-10-08
3
Medium Priority
?
432 Views
Last Modified: 2014-12-15
Dear all,

right now try to filter out table name with prefxi tblT_ so we don't want this kind of table from showing out, my query is :

 SELECT  DISTINCT TABLE_NAME 	
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA=<databaseName>  and table_type<> 'view' and TABLE_NAME  NOT LIKE 'tblT_%';

Open in new window


and I try to test the result set by only show out table has prefix like that:

 SELECT  DISTINCT TABLE_NAME 	
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA=<databaseName>  and table_type<> 'view' and TABLE_NAME  LIKE 'tblT_%';

Open in new window


but it seems MySQL will return all table with name prefix with tblT% instead of what we want : tblT_xxxxxx

how to solve this ?
0
Comment
Question by:marrowyung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 2000 total points
ID: 40370077
You are using the  wildcard chareacter in your query so you need to 'tell' My SQL engine that you want it in the name i.e.

use it like this

'
SELECT  DISTINCT TABLE_NAME 	
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA=<databaseName>  and table_type<> 'view' and TABLE_NAME  LIKE 'tblT\_%';

Open in new window

0
 
LVL 1

Author Closing Comment

by:marrowyung
ID: 40370156
very nice !
0
 
LVL 1

Author Comment

by:marrowyung
ID: 40499817
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question