I am working on a query where I need to get a certain number of rows based
on a setting BUT if the number limited does not exist then return nulls
instead.
SELECT ca.filename,ca.attributeid
FROM companyattributes ca
WHERE ca.companyid=1234
LIMIT (SELECT at.LimitMovies
FROM accounttypes AS at LEFT JOIN companies as c on
c.accounttypeid=at.accounttypeid
WHERE c.companyid=1234)
This will return the first x rows BUT obviously if none exist I get 0 rows.
If there are 2 in the limit statement I but if there are 0 found I need
something like this
attributeId | fileName
________________________
NULL NULL
NULL NULL
OR if there is actually something found -
attributeId | fileName
________________________
1 file1.jpg
2 file2.jpg
Thanks
Steffan
---------------------------------------------------------------
T E L 6 0 2 . 7 9 3 . 0 0 1 4 | F A X 6 0 2 . 9 7 1 . 1 6 9 4
Steffan A. Cline
Steffan@stripped Phoenix, Az
http://www.ExecuChoice.net USA
AIM : SteffanC ICQ : 57234309
YAHOO : Steffan_Cline MSN : steffan@stripped
GOOGLE: Steffan.Cline Lasso Partner Alliance Member
---------------------------------------------------------------
| Thread |
|---|
| • Selecting virtual rows | Steffan A. Cline | 13 Jan |