Solved

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

Posted on 2009-06-30
3
245 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 42

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
The viewer will learn how to count occurrences of each item in an array.

839 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