Reputation: 996
I'm new to SQL, and need to get the rows that have ID's greater/equal to 5 and less than/equal to 10. Is there SQL that can handle this, or should I use PHP?
Upvotes: 0
Views: 699
Reputation: 13283
Thats the cool thing about SQL. Its syntax is close to our language. You see I pretty much typed exactly what you asked for.
Select * From youTable
Where Id >= 5 AND Id <= 10
Also in T-SQL
the BETWEEN operator would include Both 5 and 10 and do the exact same thing as the previous example. From there it's your choice.
Select * From yourTable
Where Id BETWEEN 5 AND 10
Upvotes: 2
Reputation: 247650
You can use greater than or less than in your WHERE
clause.
SELECT *
FROM yourTable
WHERE Id >= 5 AND ID <= 10
Upvotes: 2