|
Posted by Geoff Muldoon on 04/11/06 06:43
legrice@nix2spam.i4free.co.nz says...
> >>> I'm looking for a SQL statement like so:
> >>>
> >>> $sql = "SELECT first 3 items for each UNIQUE user ORDER BY date_added
> >>> ASC";
> Google search gave me the following example.
>
> SQL Server:
> SELECT TOP 10 product, descr, email
> FROM products
>
> ORACLE:
> SELECT product, descr, email
> FROM products
> WHERE ROWNUM <= 10
An aside because the OP is using MySQL, but ...
Take care with Oracle if you want, as the OP indicated, to use an ORDER BY
clause, as the above will just select (without the order by) any 10 rows
and THEN do the ordering. To get it right you WILL need a nested select:
SELECT product, descr, email
FROM (
SELECT product, descr, email
FROM products
ORDER BY product
)
WHERE ROWNUM <= 10
> MySQL:
> SELECT product, descr, email
> FROM products
> LIMIT 10
>
> Google is yer friend!!!
GM
Navigation:
[Reply to this message]
|