Solved

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

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 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