MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the below queries results have only 10 rows being shown in the result displayed?
A
SELECT * FROM DataFlair;
B
SELECT name, emp ____ id FROM DataFlair Display 10;
C
Select name, location from DataFlair LIMIT 10;
D
Select Count(name) FROM DataFlair;
Explanation: 

Detailed explanation-1: -SELECT * FROM ( SELECT * FROM yourTableName ORDER BY id DESC LIMIT 10 )Var1 ORDER BY id ASC; Let us now implement the above query. mysql> SELECT * FROM (-> SELECT * FROM Last10RecordsDemo ORDER BY id DESC LIMIT 10-> )Var1->-> ORDER BY id ASC; The following is the output that displays the last 10 records.

Detailed explanation-2: -SELECT * FROM (your query ordered in reverse) alias name WHERE rownum <= Rows to return ORDER BY rownum DESC; If you want to retrieve the bottom records from a query, you need to order your results in reverse in the “your query ordered in reverse” section of the solution above.

Detailed explanation-3: -To select first 10 elements from a database using SQL ORDER BY clause with LIMIT 10. Insert some records in the table using insert command. Display all records from the table using select statement.

There is 1 question to complete.