ChrisM ChrisM - 4 months ago 30
MySQL Question

Show difference between two queries

I have one query that returns over 180k rows. After I make a slight change it returns only about 10 less.

How do I show only the 10 rows as a result?

I've tried

EXCEPT
but it seems to return a lot more than just the 10.

Answer

You can use LIMIT. This will show first n rows. Example:

SELECT * FROM Orders LIMIT 10

If you are trying to make pagination add OFFSET. It will return 10 rows starting from row 20. Example:

SELECT * FROM Orders LIMIT 10 OFFSET 20