DML & Transactions · Question 12 · Medium

DML & Transactions question 12

Table Account:
acc_no | holder | balance
101 | Farah | 5000
102 | Gopal | 12000
103 | Hema | 800
104 | Imran | 7000

The two UPDATEs run one after the other. What does the SELECT return?

UPDATE Account SET balance = balance * 2
WHERE balance < 6000;
UPDATE Account SET balance = balance - 1000
WHERE balance >= 10000;
SELECT acc_no, balance FROM Account
WHERE acc_no IN (101, 102) ORDER BY acc_no;
  1. 101, 10000; 102, 11000
  2. 101, 10000; 102, 12000
  3. 101, 9000; 102, 11000
  4. 101, 9000; 102, 12000
Answer and explanation

Answer: C. 101, 9000; 102, 11000

Explanation: The first UPDATE doubles balances below 6000, so account 101 becomes 10000 (102 is untouched). The second UPDATE sees the new values: both 10000 and 12000 are at least 10000, so each loses 1000, giving 9000 and 11000.

Previous: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |… · Next: A session is in autocommit mode (the default in MySQL, PostgreSQL and SQLite)…

Practise dml & transactions

Try a fresh set of dml & transactions questions with an explanation after every answer, free and without signing up: DML & Transactions practice. Or sit a full placement mock test.

More dml & transactions questions

More sql practice

SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge