Jump to content


Photo

SQL ID Range


  • Please log in to reply
1 reply to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 25 March 2006 - 03:04 PM

Hi all

Can you do a ID range on a sql statement, so it shows ID numbers 1 -200 for example?

I use the following code for a simple statement

SELECT * FROM users

Can a WHERE ID = 1 -200 be used? Or am I writting the wrong code?

Thanks in advance

Ed

#2 annihilate

annihilate
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationUK

Posted 25 March 2006 - 04:52 PM

Is it just the first 200 rows you want? If so you can use this.
SELECT id FROM users ORDER BY id LIMIT 200;

Or if you do actually only want the rows with id between 1 and 200, then use this:
SELECT id FROM users WHERE id BETWEEN 1 AND 200;

Personal site: NewEnigma  |  Java and JSF Discussion




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users