COMPUTER SCIENCE AND ENGINEERING
SQL
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
SELECT * FROM DataFlair;
|
|
SELECT name, emp ____ id FROM DataFlair Display 10;
|
|
Select name, location from DataFlair LIMIT 10;
|
|
Select Count(name) FROM DataFlair;
|
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.