Search code examples
sqlsql-updatesetcorrectness

Preferred method of updating and setting SQL


I'm learning SQL at the moment, and have found some different methods of updating and setting a table.

For this example, I am wondering what is the "most correct way" of doing this?

    UPDATE student
    SET test1 = 7, test2 = 9
    where stuid = 999

or

    UPDATE student
    SET test1 = 7
    where stuid = 999
    UPDATE student
    SET test2 = 9
    where stuid = 999

Thanks.


Solution

  • Firstly always Google yourself before posting any Questions.

    The answer (as said by others) is off-course the Method 1. As it will not reload the database Twice.

    Also if you are Beginner try to go learn from W3Schools