Reputation: 147
I'm trying to run a single SQL command which will update table 'name', where the column 'id' matches 'eg1', 'eg2' and 'eg3'. The column to be updated is 'status' and should be changed to 'new_status' for the previously specified ids only.
Unfortunately I'm new with SQL, therefore I only got as far as this which doesn't seem to be working:
SELECT * FROM `tblhosting` WHERE 'id' IN (eg1,eg2,eg3) UPDATE 'status' SET new_status
Upvotes: 0
Views: 28
Reputation: 108370
String literals are enclosed in single quotes.
Identifiers can be optionally enclosed in backtick characters.
The syntax for an UPDATE
statement is like this:
UPDATE `tblhosting`
SET `status` = 'new_status'
WHERE `id` IN ('eg1','eg2','eg3')
The specification is a little ambiguous. The example above searches the table named tblhosting
for rows to be updated, and assigns a value to the status
column. This assumes that the value to be assigned is a string literal "new_status"
, and that "eg1"
, "eg2"
and "eg3"
are string values found in the column named id
.)
Upvotes: 1
Reputation: 35323
Update tblhosting set status = 'new_status' where id in ('eg1','eg2','eg3')
This assuems you want to update tblhosting column status set to 'new_status' where the ID is either eg1, eg2 or eg3.
Upvotes: 2
Reputation: 1513
update tblhosting
set new_status = 'status' WHERE 'id' IN (eg1,eg2,eg3)
Upvotes: 0