|
Home > Archive > MySQL ODBC Connector > April 2006 > on select statements
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
on select statements
|
|
| Yemi Obembe 2006-04-03, 7:32 am |
| ------=_Part_7317_3069358.1144066486903
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
what is the difference between this:
SET @a=3D1; PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?';EXECUTE STMT USIN=
G
@a;
and this:
'SELECT * FROM tbl LIMIT 1
And then this:
SET @skip=3D1; SET @numrows=3D5;
PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?, ?';
EXECUTE STMT USING @skip, @numrows;
and this:
'SELECT * FROM tbl LIMIT 1,5
------=_Part_7317_3069358.1144066486903--
| |
| sheeri kritzer 2006-04-03, 1:29 pm |
| There is no logical difference. There's a tiny bit of overhead in
preparing and executing the statements, but if you have a query where
the limit is variable, a prepared statement might be better than
coding within an application, because then when ANY user or
application connects it can use that prepared statement.
-Sheeri
On 4/3/06, Yemi Obembe <ray@ngbot.com> wrote:
> what is the difference between this:
>
> SET @a=3D1; PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?';EXECUTE STMT US=
ING
> @a;
>
> and this:
> 'SELECT * FROM tbl LIMIT 1
>
> And then this:
>
> SET @skip=3D1; SET @numrows=3D5;
> PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?, ?';
> EXECUTE STMT USING @skip, @numrows;
>
> and this:
> 'SELECT * FROM tbl LIMIT 1,5
>
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw
|
|
|
|
|