mohansinfh — 2011-08-29T08:58:35-04:00 — #1
Can someone tell me the SQL Command to make changes to a certain number of entries.
For example If I have 2 columns in a table namely, id & status.
Now if I want to change status=1 on records from id=1 to 10,
How to do this?
guido2004 — 2011-08-29T09:00:10-04:00 — #2
mohansinfh — 2011-08-29T09:14:32-04:00 — #3
mohansinfh — 2011-08-29T12:07:39-04:00 — #4
Hi I tried it, but it's not working.
UPDATE [LOW_PRIORITY] [IGNORE] table_name
[WHERE 'id'>1 AND 'id'<10]
r937 — 2011-08-29T12:14:35-04:00 — #5
remove the square brackets, which are used in the syntax in the manual to show words or clauses that are optional
also, don't put single quotes around your column names, that just turns them into strings
also, don't put quotes around numeric values that will be compared with or assigned to numeric columns -- it'll work in mysql (but not in other databases), but the conversion from string to number is needless overhead
SET status = 1
WHERE id > 1
AND id < 10
mohansinfh — 2011-08-29T12:23:10-04:00 — #6