Solved

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

Posted on 2009-06-30
3
244 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
3 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 400 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 100 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

809 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