Unlimited Usenet
day retention, 99% Completion, Unlimited Access, Free Trial!

mysqldump - conditional where clause with two tables ??

This is a discussion on mysqldump - conditional where clause with two tables ?? within the MySQL Database forums, part of the Database Forums category; I am trying to get a conditional mysqldump from two related, based on a specified relationship between the table records, ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-28-2009
Tim
 
Posts: n/a
Default mysqldump - conditional where clause with two tables ??

I am trying to get a conditional mysqldump from two related, based on
a specified relationship between the table records, and I am having
trouble constructing the statement. Here is the situation.

Two tables are involved, configured as follows:
company (
company_id,
...
)

company_site (
company_id,
site_id
)

I want to get a dump of both company records and corresponding
company_site records for a specified site_id. I tried the following
mysqldump command:

(Values in <...> are placeholders, not the actual values used)

mysqldump --user="<username>" --password="<password>"
--where="company.company_id=company_site.company_id and
company_site.site_id=<site_id>" wsadev_main company company_site >
text_company_dump.txt;

I get the following error message:
Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `company`
WHERE company.company_id=company_site.company_id and
company_site.site_id=<site_id>': Unknown column
'company_site.company_id' in 'where clause' (1054)

Does mysqldump have the capacity to conduct selective dumps of table
records on more than one table; and, if so, what is the proper
construction of the command?

Tim
Reply With Quote
  #2 (permalink)  
Old 04-29-2009
toby
 
Posts: n/a
Default Re: mysqldump - conditional where clause with two tables ??

On Apr 28, 9:27*am, Tim <t...@nowhere.com> wrote:
> I am trying to get a conditional mysqldump from two related, based on
> a specified relationship between the *table records, ...
> Does mysqldump have the capacity to conduct selective dumps of table
> records on more than one table; and, if so, what is the proper
> construction of the command?
>
> Tim


I don't think mysqldump is capable of any kind of join. So you are
going to be limited to SELECT and SELECT INTO OUTFILE.

Reply With Quote
  #3 (permalink)  
Old 04-29-2009
Tim
 
Posts: n/a
Default Re: mysqldump - conditional where clause with two tables ??

On Tue, 28 Apr 2009 23:42:55 -0700 (PDT), toby
<toby@telegraphics.com.au> wrote:

>On Apr 28, 9:27*am, Tim <t...@nowhere.com> wrote:
>> I am trying to get a conditional mysqldump from two related, based on
>> a specified relationship between the *table records, ...
>> Does mysqldump have the capacity to conduct selective dumps of table
>> records on more than one table; and, if so, what is the proper
>> construction of the command?
>>
>> Tim

>
>I don't think mysqldump is capable of any kind of join. So you are
>going to be limited to SELECT and SELECT INTO OUTFILE.


Thanks. That is quite helpful. At least I can now solve the problem.
Tim
Reply With Quote
  #4 (permalink)  
Old 04-29-2009
Michael Austin
 
Posts: n/a
Default Re: mysqldump - conditional where clause with two tables ??

Tim wrote:
> I am trying to get a conditional mysqldump from two related, based on
> a specified relationship between the table records, and I am having
> trouble constructing the statement. Here is the situation.
>
> Two tables are involved, configured as follows:
> company (
> company_id,
> ...
> )
>
> company_site (
> company_id,
> site_id
> )
>
> I want to get a dump of both company records and corresponding
> company_site records for a specified site_id. I tried the following
> mysqldump command:
>
> (Values in <...> are placeholders, not the actual values used)
>
> mysqldump --user="<username>" --password="<password>"
> --where="company.company_id=company_site.company_id and
> company_site.site_id=<site_id>" wsadev_main company company_site >
> text_company_dump.txt;
>
> I get the following error message:
> Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `company`
> WHERE company.company_id=company_site.company_id and
> company_site.site_id=<site_id>': Unknown column
> 'company_site.company_id' in 'where clause' (1054)
>
> Does mysqldump have the capacity to conduct selective dumps of table
> records on more than one table; and, if so, what is the proper
> construction of the command?
>
> Tim


Well, it sort-of does... as long as the data gets imported into a single
table...

create a view using your query and use mysqldump to export that data
using --tables
Reply With Quote
  #5 (permalink)  
Old 04-29-2009
toby
 
Posts: n/a
Default Re: mysqldump - conditional where clause with two tables ??

On Apr 29, 9:49*am, Michael Austin <maus...@firstdbasource.com> wrote:
> Tim wrote:
> > I am trying to get a conditional mysqldump from two related, based on
> > a specified relationship between the *table records, and I am having
> > trouble constructing the statement. *Here is the situation.

>
> > Two tables are involved, configured as follows:
> > company (
> > * *company_id,
> > * *...
> > * *)

>
> > company_site (
> > * *company_id,
> > * *site_id
> > * * * * * *)

>
> > I want to get a dump of both company records and corresponding
> > company_site records for a specified site_id. *I tried *the following
> > mysqldump command:

>
> > (Values in <...> are placeholders, not the actual values used)

>
> > *mysqldump --user="<username>" --password="<password>"
> > --where="company.company_id=company_site.company_id and
> > company_site.site_id=<site_id>" wsadev_main company company_site >
> > text_company_dump.txt;

>
> > I get the following error message:
> > Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `company`
> > WHERE company.company_id=company_site.company_id and
> > company_site.site_id=<site_id>': Unknown column
> > 'company_site.company_id' in 'where clause' (1054)

>
> > Does mysqldump have the capacity to conduct selective dumps of table
> > records on more than one table; and, if so, what is the proper
> > construction of the command?

>
> > Tim

>
> Well, it sort-of does... as long as the data gets imported into a single
> table...
>
> create a view using your query and use mysqldump to export that data
> using --tables


Brilliant.
Reply With Quote
  #6 (permalink)  
Old 04-30-2009
Michael Austin
 
Posts: n/a
Default Re: mysqldump - conditional where clause with two tables ??

toby wrote:
> On Apr 29, 9:49 am, Michael Austin <maus...@firstdbasource.com> wrote:
>> Tim wrote:
>>> I am trying to get a conditional mysqldump from two related, based on
>>> a specified relationship between the table records, and I am having
>>> trouble constructing the statement. Here is the situation.
>>> Two tables are involved, configured as follows:
>>> company (
>>> company_id,
>>> ...
>>> )
>>> company_site (
>>> company_id,
>>> site_id
>>> )
>>> I want to get a dump of both company records and corresponding
>>> company_site records for a specified site_id. I tried the following
>>> mysqldump command:
>>> (Values in <...> are placeholders, not the actual values used)
>>> mysqldump --user="<username>" --password="<password>"
>>> --where="company.company_id=company_site.company_id and
>>> company_site.site_id=<site_id>" wsadev_main company company_site >
>>> text_company_dump.txt;
>>> I get the following error message:
>>> Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `company`
>>> WHERE company.company_id=company_site.company_id and
>>> company_site.site_id=<site_id>': Unknown column
>>> 'company_site.company_id' in 'where clause' (1054)
>>> Does mysqldump have the capacity to conduct selective dumps of table
>>> records on more than one table; and, if so, what is the proper
>>> construction of the command?
>>> Tim

>> Well, it sort-of does... as long as the data gets imported into a single
>> table...
>>
>> create a view using your query and use mysqldump to export that data
>> using --tables

>
> Brilliant.



yeah, I know :)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:47 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0