Solved

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

Posted on 2009-06-30
3
240 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now