Unix Technical Forum

SQL command to show only databases that contain a particular table

This is a discussion on SQL command to show only databases that contain a particular table within the MySQL forums, part of the Database Server Software category; --> I have several databases that are used to collect data for different client-projects. My intention was to collect the ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:30 AM
judy
 
Posts: n/a
Default SQL command to show only databases that contain a particular table

I have several databases that are used to collect data for different
client-projects. My intention was to collect the data, and administer
mySQL so each client could see only their data. Each of these
databases used to collect data have the same tables. There are other
databases which are available to all the users which contain common
information.

The command "show databases" lists all of the databases (visible to
the particular user) and not the one's I would like to display (the
databases used to collect data). Is there a way to nest a single
mySQL command to show only the databases that have the same particular
table?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:30 AM
lark
 
Posts: n/a
Default Re: SQL command to show only databases that contain a particular table

== Quote from judy (judy@shaw.ca)'s article
> I have several databases that are used to collect data for different
> client-projects. My intention was to collect the data, and administer
> mySQL so each client could see only their data. Each of these
> databases used to collect data have the same tables. There are other
> databases which are available to all the users which contain common
> information.
> The command "show databases" lists all of the databases (visible to
> the particular user) and not the one's I would like to display (the
> databases used to collect data). Is there a way to nest a single
> mySQL command to show only the databases that have the same particular
> table?


yes, potentially you can write a stored procedure to do this. you'll save the
procedure in each database separately of course.
--
POST BY: lark with PHP News Reader ;o)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:30 AM
=?ISO-8859-1?B?QW5kcukgSORuc2Vs?=
 
Posts: n/a
Default Re: SQL command to show only databases that contain a particulartable

On 5 Dez., 18:03, judy <j...@shaw.ca> wrote:
> Is there a way to nest a single
> mySQL command to show only the databases that have the same particular
> table?


You mean something like this?

SELECT DISTINCT TABLE_SCHEMA FROM information_schema.TABLES WHERE
TABLE_NAME = 'the_table_name_you_look_for'

Regards,
André
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 10:30 AM
Captain Paralytic
 
Posts: n/a
Default Re: SQL command to show only databases that contain a particulartable

On 5 Dec, 23:28, "André Hänsel" <an...@webkr.de> wrote:
> On 5 Dez., 18:03, judy <j...@shaw.ca> wrote:
>
> > Is there a way to nest a single
> > mySQL command to show only the databases that have the same particular
> > table?

>
> You mean something like this?
>
> SELECT DISTINCT TABLE_SCHEMA FROM information_schema.TABLES WHERE
> TABLE_NAME = 'the_table_name_you_look_for'
>
> Regards,
> André


Except that will show tables not databases.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 10:30 AM
=?ISO-8859-1?B?QW5kcukgSORuc2Vs?=
 
Posts: n/a
Default Re: SQL command to show only databases that contain a particulartable

On 6 Dez., 10:53, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 5 Dec, 23:28, "André Hänsel" <an...@webkr.de> wrote:
>
> > On 5 Dez., 18:03, judy <j...@shaw.ca> wrote:

>
> > > Is there a way to nest a single
> > > mySQL command to show only the databases that have the same particular
> > > table?

>
> > You mean something like this?

>
> > SELECT DISTINCT TABLE_SCHEMA FROM information_schema.TABLES WHERE
> > TABLE_NAME = 'the_table_name_you_look_for'

>
> > Regards,
> > André

>
> Except that will show tables not databases.


Of course it shows databases, TABLE_SCHEMA contains the name of the
database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:08 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com