[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to make this mysql query: Alter values from only record x to record y

Posted on 2009-06-30
3
Medium Priority
?
249 Views
Last Modified: 2013-12-13
HI,

id is the primary key of my database:

I want to run a query where I alter all values from column "name" where id values betweeen 100 and 500.

let's say I want to change all names from database for ids between 100 and 500 ?

How this query is?
0
Comment
Question by:Fernanditos
[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
3 Comments
 
LVL 43

Accepted Solution

by:
pcelba earned 1600 total points
ID: 24750599
Use the following (and easy) UPDATE statement:

UPDATE table SET name = 'Yor new value' WHERE id BETWEEN 100 and 500

More info about MySQL syntax is e.g. here: http://dev.mysql.com
0
 

Author Comment

by:Fernanditos
ID: 24750692
Hi,

Im getting error, here is the query with real values:

Whats wrong? I get this:

Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table SET category = 'Marketing and Ads' WHERE ide BETWEEN 22809 and 24066' at line 1
UPDATE TABLE SET category = 'Marketing and Ads' WHERE ide BETWEEN 22809 AND 24066

Open in new window

0
 
LVL 8

Assisted Solution

by:stefanx
stefanx earned 400 total points
ID: 24750721
Replace TABLE with the name of your table, so if your table is called MyData, then it should be

UPDATE MyData SET category = 'Marketing and Ads' WHERE ide BETWEEN 22809 AND 24066

Also make sure that your id column is really called ide as you have above ;)
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

649 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