I was trying to update multiple columns in the mysql database. Mysql database did not report any issue with my syntax , it even executed it successfully - but it actually did not update even a single field in the database. The problem was using 'and' in updating multiple columns. It even passes mysql validation for a well-formed query.
Here is an example:
Update query (which executed successfully but does not do anything)
update documents
set doc_blob_content=null
and doc_type='try'
and doc_name='try'
and doc_content_type='try'
and doc_size='123'
and last_updated_by='sujie'
and last_updated_date='2009-08-28 21:52:01'
where task_id=7458
To get the above to work, replace all 'with ','
update documents
set doc_blob_content=null,
doc_type='doc',
doc_name='new',
doc_content_type='pdf',
doc_size=1,
last_updated_by='nkdf',
last_updated_date='2008-08-28 21:52:01'
where task_id=7458
No comments:
Post a Comment
Please feel free to post your comments!