mysqlsqlrdbmsmultiple-choice

What is the result of the following query?


DELETE FROM student WHERE marks < (SELECT avg(marks) FROM student);

a) The query deletes all the tuples whose marks are greater than the average marks

b) The query deletes all the tuples whose marks are less than the average marks

c) The query deletes all the values under the marks attribute which are less than the average

d) The query is syntactically wrong and does not execute


Solution

  • d) The query is syntactically wrong and does not execute

    You can not delete the rows from the same data source which your sub query refers to.

    In other words in MySQL, you can’t modify the same table which you use in the SELECT part. This behavior is documented here.