mysql - SQL Replace Other Column -
i've got joomla database need replace entries in "created_by" column new user id, replacement based on entries in "created_by_alias" column.
╔════════════╦══════════════╗
║ created_by ║ created_by_alias ║
╠════════════╬══════════════╣
║ 62 ║ bob dole ║
║ 62 ║ bill clinton ║
║ 62 ║ bob dole ║
║ 62 ║ hillary clinton ║
╚════════════╩══════════════╝
so, need created_by replaced 1500 when "created_by_alias" bob dole; 1550 when "created_by_alias" bill clinton; 1600 when "created_by_alias" hillary clinton.
i have come following query isn't working:
update candidates set created_by = 1500 created_by_alias (select * candidates created_by_alias 'bob dole')
i error: #1241 - operand should contain 1 column(s)
what missing? in no way coder or query expert , usual resource busy uw exams @ moment.
i think mean:
update candidates set created_by = 1500 created_by_alias ='bob dole'
the error you're getting because subselect returning 2 fields (62, 'bob dole')
, , 2 rows well. error trying tell you, can test 1 value against 1 field (unless use in
clause)
Comments
Post a Comment