MysQL & MS-SQL conversion

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

MysQL & MS-SQL conversion

Post by quadoc »

I've the following statement in MySql, could someone tell me how to convert that to a MS-SQL statement. Thanks...

Code: Select all

$showtickets = mysql_query("SELECT * FROM `tickets` WHERE open='$tixstatus' AND dep='$dep' $s_sort LIMIT ".$i_limit_start.", ".$g_limit ." ");
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

unforutnately mssql doesn't have a limit function:

you'll probably have to do something like this:

Code: Select all

$showtickets = mssql_query("SELECT TOP ".$g_limit." * FROM tickets");
then skip through your first $i_limit_start value.

or you could use a subquery to select TOP $g_limit and subquery out the ones before it....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

google: limit mysql mssql

you'll find all the bits in the next few links, usually..
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post by quadoc »

Thanks for the tips guys... :)
Post Reply