SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Limit + Mssql
-
Feb 15, 2006, 10:35 #1
- Join Date
- Apr 2004
- Location
- dublin
- Posts
- 2,036
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Limit + Mssql
Hi all,
What is the equivalent of mysql's LIMIT clause for MSSQL Server?
Thanks.
PHP Code:$find_date = mssql_query("select date from date where date = '$value'
and course_ID = '$course' LIMIT 1");
-
Feb 15, 2006, 10:46 #2
- Join Date
- Aug 2003
- Location
- CT
- Posts
- 643
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
SELECT Top X from table
keep in mind, MS doesn't support limit X,Y for starting ranges.
-
Feb 15, 2006, 11:39 #3
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
kev, are you sure this is what you're running in MySQL --
Code:select date from date where date = '$value' and course_ID = '$course' LIMIT 1
you are returning the "date" value but of course you could really return anything, right? i mean, because you already know the "date" value
so you could do this in SQL Server --Code:select 'Yep!' where exists ( select 937 from date where date = '$value' and course_ID = '$course' )
-
Feb 16, 2006, 03:37 #4
- Join Date
- Apr 2004
- Location
- dublin
- Posts
- 2,036
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Rudy,
I'm using LIMIT to display just one result. So is the above right in what I want to do?
-
Feb 16, 2006, 05:21 #5
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
is it right for what you're trying to do?
that depends on what you're trying to do, which, and please don't take this the wrong way, you haven't communicated very well at all
is the same course available on the same day more than once?
-
Feb 16, 2006, 07:13 #6Code:
SELECT TOP 1 * FROM table ORDER BY field
Bookmarks