64 736
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #25186 in Databases | SQL | Oracle | MS Access for Joe

Question #25186
I am trying to update a field in MySql:

the basic premis is:

FIeld X = Field Y + 30 (both X and Y are numeric)

Both fields are in the same table.

I tried update <tablename> set X = (Y+30) where condition = Z

I then tried update <tablename> set X = sum (Y+30) where condition = Z

both failed. Can you help?

Expert's answer
There are some rules for updating field in MySQL table:
&
1. At the update moment table must exists in database
2. if X-field has PRIMARYor UNIQUE& key property - You must exclude inserting of duplicate values into that field, or have to use syntax: &quot;UPDATE [IGNORE] tbl_name...&quot;. So duplicate values will be excluded and update will execute without an error messages.
3. Table names used with schema name, so Your sql-command must has format as:

update schema_name.tablename set X = (Y+30) where condition = Z
&
4. Check - You have enough DB rights to update tables.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions