?
Solved

mysqldump with multiple where conditions

Posted on 2008-11-06
9
Medium Priority
?
1,479 Views
Last Modified: 2012-05-05
I'm Trying to do a mysqldump with multiple where conditions:

mysqldump -h myhost --user=myuser --password=mypass --no-create-info --opt where="sDate<2007-10-10 OR cDate>2008-09-30 OR pDate<2008-10-10" MyDB ProposedTo |sed -e \"s|INSERT INTO|REPLACE INTO|\" 2>&1 > proposeto-replace.sql
0
Comment
Question by:SaltyDawg
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Expert Comment

by:jools
ID: 22897539
....and...
A. It's all gone very well and I just wanted a chat [ ]
B. Oh dear, it doesnt work and this is what happens.... [ ]
C. It's the weekend and I'm about to go home [ ]

   tick as appropriate
0
 
LVL 1

Author Comment

by:SaltyDawg
ID: 22898170
So you saying this should be correct?
0
 
LVL 26

Expert Comment

by:Umesh
ID: 22898315
Pls try this..
mysqldump -hmyhost --user=myuser --password=mypass --no-create-info --opt --where="sDate < \"2007-10-10\" OR cDate > \"2008-09-30\" OR pDate  < \"2008-10-10\"" MyDB --tables ProposedTo |sed -e \"s|INSERT INTO|REPLACE INTO|\" 2>&1 > proposeto_replace.sql

Open in new window

0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 19

Expert Comment

by:jools
ID: 22899012
I'm saying you've not told us what you were trying to achieve and if it was a problem.

More like a statement than a question, if you like...
0
 
LVL 1

Author Comment

by:SaltyDawg
ID: 22899535
jools:

I apologize but I thought it was pretty obvious.

"I'm Trying to do a mysqldump with multiple where conditions:" and  I've shown the code I used. I assumed it was understand that what I have so far is not working, because why would I post code that was already working. Trust me, and no offense, but I would not waste my time posting a question just for idle chat.
0
 
LVL 26

Expert Comment

by:Umesh
ID: 22901792
Did you check which I posted??
0
 
LVL 1

Author Comment

by:SaltyDawg
ID: 22907671
Yes I checked it. I think I see where my issue lies.

The posted I submitted was only a few conditions. But what I am actually looking to do is create a list of conditions into the where.

Basically I may have:

IndexNumber = 50013157000000 OR IndexNumber = 50013171000000

over 100 times.

I was retrieving a list of indexnumbers then creating the where condition based on it.

I actually have something like this:

mysqldump -h myhost --user=mypass --password=mypass --no-create-info --opt --where="IndexNumber='50013157000000' OR IndexNumber='50013171000000' OR IndexNumber='50013169000000' OR IndexNumber='50008262040000' OR IndexNumber='50010968010200' OR IndexNumber='50013013000000' OR IndexNumber='50012269010000' OR IndexNumber='50012265010000' OR IndexNumber='50012925010000' OR IndexNumber='50013140000100' OR IndexNumber='50012994010000' OR IndexNumber='50013097030000' OR IndexNumber='50012630000100' OR IndexNumber='50013159000000' OR IndexNumber='50009794000001' OR IndexNumber='50013097020000' OR IndexNumber='50006328020001' OR IndexNumber='50013153010000' OR IndexNumber='50009668060000' OR IndexNumber='50011104010000' OR IndexNumber='50008521050000' OR IndexNumber='50012919000000' OR IndexNumber='50012939000000' OR IndexNumber='50013162000000' OR IndexNumber='50013165000000' OR IndexNumber='50012938000000' OR IndexNumber='50013106000000' OR IndexNumber='50013119000000' OR IndexNumber='50012616010000' OR IndexNumber='50012023030000' OR IndexNumber='50013149000000' OR IndexNumber='50007324020000' OR IndexNumber='50012705000002' OR IndexNumber='50011718000004' OR IndexNumber='50005495030001' OR IndexNumber='50013144000000' OR IndexNumber='50002722110000' OR IndexNumber='50009062020000' OR IndexNumber='50013181000000' OR IndexNumber='50009805010000' OR IndexNumber='50011772010000' OR IndexNumber='50013183000000' OR IndexNumber='50013182000000' OR IndexNumber='50000997011600' OR IndexNumber='50009796040100' OR IndexNumber='50010041160000' OR IndexNumber='50009614030000' OR IndexNumber='50010533000001' OR IndexNumber='50009614040000' OR IndexNumber='50008836020000' OR IndexNumber='50012850020000' OR IndexNumber='50008057000100' OR IndexNumber='50013121000000' OR IndexNumber='50011951020100' OR IndexNumber='50010250030000' OR IndexNumber='50013142000000' OR IndexNumber='50012960010000' OR IndexNumber='50012957000000' OR IndexNumber='50012070010000' OR IndexNumber='50013145000000' OR IndexNumber='50013145010000' OR IndexNumber='50012961000000' OR IndexNumber='50013047000000' OR IndexNumber='50005086040200' OR IndexNumber='50013175000000' OR IndexNumber='50002093070100' OR IndexNumber='50007776090000' OR IndexNumber='50013179000000' OR IndexNumber='50013173000000' OR IndexNumber='50013154000000' OR IndexNumber='50009795010400' OR IndexNumber='50009319010000' OR IndexNumber='50012850030000' OR IndexNumber='50013118000000' OR IndexNumber='50013122000000' OR IndexNumber='50004968010000' OR IndexNumber='50009302020000' OR IndexNumber='50013137000000' OR IndexNumber='50013136000000' OR IndexNumber='50013141000000' OR IndexNumber='50008637050000' OR IndexNumber='50011421010000' OR IndexNumber='50013146000000' OR IndexNumber='50013148000000' OR IndexNumber='50013152000000' OR IndexNumber='50011663020000' OR IndexNumber='50003777030000' OR IndexNumber='50003259060000' OR IndexNumber='50012967000000' OR IndexNumber='50003259030100' OR IndexNumber='50003146000001' OR IndexNumber='50012964000100' OR IndexNumber='50013184000000' OR IndexNumber='50012942000000' OR IndexNumber='50011639010000' OR IndexNumber='50013178000000' OR IndexNumber='50006418040001' OR IndexNumber='50012917000000' OR IndexNumber='50012030020000' OR IndexNumber='50012885010000' OR IndexNumber='50013158000000' OR IndexNumber='50013153000000' OR IndexNumber='50010423010000' OR IndexNumber='50003090020000' OR IndexNumber='50013185000000' OR IndexNumber='50012030030000' OR IndexNumber='50013186000000' OR IndexNumber='50013111010000' OR IndexNumber='50012260010000' OR IndexNumber='50013187000000' OR IndexNumber='50001371000001' OR IndexNumber='50012806010000' OR IndexNumber='50005086040300' OR IndexNumber='50013187010000' OR IndexNumber='50012948000000' OR IndexNumber='50013021020000' OR IndexNumber='50012793000001' OR IndexNumber='50010986040000' OR IndexNumber='50011451070000' OR IndexNumber='50003440110000' OR IndexNumber='50012951000000'" myDB ProposedTo |sed -e "s|INSERT INTO|REPLACE INTO|" 2>&1 > proposedto-replace.sql;

When I ran it I got:

msqldump: Error in field count fot table: 'ProposedTo ! Aborting.

So that made me think the issue has to do with the where clause having a limitation of how many conditions it could have. Is there a Limit? If so would breaking it down to multiple mysqldump statements be best?
0
 
LVL 26

Accepted Solution

by:
Umesh earned 2000 total points
ID: 22912536
This is really strange error for me.. Did you see any error code in that?

Can you give a try for this.??

In your where condition instead of OR OR...

IndexNumber IN (50013157000000, etc etc)
0
 
LVL 26

Expert Comment

by:Umesh
ID: 22916308
Did you try the one I suggested in above comment??
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

755 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