Solved

filter out mySQL table name

Posted on 2014-10-08
3
415 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
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

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