Eduardo Morras wrote:
> Clemens Ladisch <clemens at ladisch.de> wrote:
>> ... WHERE cb_seq_num > (
>>       SELECT cb_seq_num
>>       FROM ordercallback
>>       WHERE cb_uuid=@CBUUID
>>       UNION ALL
>>       SELECT NULL   -- at least one result
>>       LIMIT 1)      -- at most one result
>
> Shouldn't add an ORDER BY cb_seq_num to get the lower one?
>
> ...
> WHERE cb_uuid=@CBUUID
> ORDER BY cb_seq_num ASC
> UNION ALL
> ...

ORDER BY is not allowed at this place; it could be applied only to the
entire compound subquery.  (If you really want the lowest ID, you have
to use another subquery.)

In this case, if there actually is more than one result from cb_seq_num,
something is wrong with the query or the data, and an error message
could be appropriate.


Regards,
Clemens

Reply via email to