

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: LIMIT
incomplete
2: Limit Quiz
incomplete
3: ORDER BY
incomplete
4: ORDER BY Quiz
incomplete
5: ORDER BY and LIMIT
incomplete
6: Query Practice – Security Breach
incomplete
This lesson's interactive features are locked, please to keep using them
Sometimes we don't want to retrieve every record from a table. For example, it's common for a production database table to have millions of rows, and SELECTing all of them might crash your system! The LIMIT keyword has entered the chat.
LIMIT can be used at the end of a SELECT statement to set a cap on the number of records returned.
SELECT * FROM products
WHERE product_name LIKE '%berry%'
LIMIT 50;
The query above retrieves all the records from the products table where the name contains the word berry. If we ran this query on the Amazon database, it would almost certainly return a lot of records.
The LIMIT clause only allows the database to return up to 50 records matching the query. This means that if there aren't that many records matching the query, LIMIT will not have an effect.
A lot of our users have been using CashPal to pay other users for lunch. Let's take a look at a sample of that data.
Write a query that returns all rows and fields from the transactions table, with the following conditions:
note field has the word lunch in it.