Author Topic: [SOLVED] SQL equivalent for MySQL "LIMIT"?...  (Read 548 times)

0 Members and 1 Guest are viewing this topic.

Offline ShootingBlanksTopic starter

  • Enthusiast
  • Posts: 209
    • View Profile
[SOLVED] SQL equivalent for MySQL "LIMIT"?...
« on: July 25, 2008, 03:03:07 PM »
Hello.

I know that if I wanted, say, records 6-10 of a query in MySQL I'd just tack on "LIMIT 5,5" to the end of my query.  But what about in SQL?  Is that possible?...

I know to get the first, say, 15 records you'd say "SELECT TOP(15)" but I don't know how to select a certain number of records starting from in the middle of the recordset...

Thanks!...

Offline ShootingBlanksTopic starter

  • Enthusiast
  • Posts: 209
    • View Profile
Re: SQL equivalent for MySQL "LIMIT"?...
« Reply #1 on: July 25, 2008, 05:36:19 PM »
Nevermind! - found a solution here, in case anyone's interested.  It worked great for me:

http://www.tech-recipes.com/rx/1868/mimic_the_mysql_limit_feature_in_microsoft_sql_server


Offline Barand

  • Sen . (ile || sei)
  • Staff Alumni
  • 'Mind Boggling!'
  • *
  • Posts: 15,132
  • Gender: Male
  • php 4.3/5.1 MySql 5.0.1
    • View Profile
Re: SQL equivalent for MySQL "LIMIT"?...
« Reply #2 on: July 25, 2008, 06:39:11 PM »
Another way to get rows 20-29 with MS-SQL is

SELECT TOP 10 * FROM mytable
WHERE id NOT IN
(SELECT TOP 20 id FROM mytable)
|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: [SOLVED] SQL equivalent for MySQL "LIMIT"?...
« Reply #3 on: July 26, 2008, 03:21:10 PM »
I've actually used that one, Barand... couldn't believe it had to be so "forced".
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

Offline Barand

  • Sen . (ile || sei)
  • Staff Alumni
  • 'Mind Boggling!'
  • *
  • Posts: 15,132
  • Gender: Male
  • php 4.3/5.1 MySql 5.0.1
    • View Profile
Re: [SOLVED] SQL equivalent for MySQL "LIMIT"?...
« Reply #4 on: July 26, 2008, 06:05:34 PM »
Hard to believe how a RDBMS with so much money behind it can have so little functionality. Compare it's handful of datetime functions with MySQL's, for example
|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: [SOLVED] SQL equivalent for MySQL "LIMIT"?...
« Reply #5 on: July 28, 2008, 10:49:17 AM »
Compare it's handful of datetime functions with MySQL's, for example
No kidding... I nearly threw up trying to figure out the equivalent of DATE(myDateTimeField)... all those "magic" numbers and CASTing.... ugh.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.