The Sql Update Statement

The Sql Update Statement

  • We use the sql update statement to update datas of tables in databases
  • If we don’t write conditions, the table’s all records are updated
  • It’s the one of DML(Data Manupulation Language) codes

The Sql Update Syntax

or to update all Data:

TO DOWNLOAD THE SAMPLE LİBRARY DATABASE CLICK

The Sql Update Examples on Library Database

Sample 1: Update the student where the student_id equal to 30,new name Taylar

Result Of The Query: 1 row(s) affected.

Sample 2: Update all student’s point to zero

Result Of The Query: 505 row(s) affected.

Sample 3: Add 10 points to all Student

or

Result Of The Query: 505 row(s) affected.

Sample 4: Add 10 points to students who read ‘The Hobbit’ named book

Update students set point += 10 where studentId in (Select distinct studentId from borrows join books on borrows.bookId = books.bookId and books.name = 'Bleak House')

Result Of The Query: 38 row(s) affected.

YOU MAY WANT TO SEE OUR ALL EXAMPLES PAGE, THEN CLICK HERE

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: