[OT} Any SQL Experts Here?

Christopher Browne cbbrowne-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Thu May 28 15:30:21 UTC 2009


On Thu, May 28, 2009 at 10:06 AM, Alexander Short
<Alexander.Short-V7Ve2fXh0sTQT0dZR+AlfA at public.gmane.org> wrote:
> One way and there is perhaps better, is to use a sub-select.  This is
> one way of doing it at least in T-SQL using MS SQL (what I'm more
> familiar with)
>
> SELECT  a.*,COUNT(b.*),(SELECT TOP 1 b2.FIELD FROM TABLEB b2 WHERE
> b2.KEY1 = a.KEY1 AND b2.KEY2 = a.KEY2)
> FROM    TABLEA a
> JOIN    TABLEB b
> ON      a.KEY1 = b.KEY1
> AND     a.KEY2 = b.KEY2
> GROUP BY a.KEY1,a.KEY2

That's a subquery, and MySQL(an Oracle TM) only started supporting
them comparatively recently.

I don't believe "SELECT TOP 1" is either standard SQL, nor supported
by MySQL(an Oracle TM).
-- 
http://linuxfinances.info/info/linuxdistributions.html
Mitch Hedberg  - "My fake plants died because I did not pretend to
water them." - http://www.brainyquote.com/quotes/authors/m/mitch_hedberg.html
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list