Thursday, 15 July 2010

mysql - Listing elements of my table -


I doubt a table in the listing record where I use: JOIN, MAX, GROUP BY < P> I am using the following question:

  Select a CR. * Include one to CP CNNER in cliche_revisao cr on c.cliche_pk = cr.cliche_pk a WHERE cr.numero = (Select MAX (number) from cliche_revisao WHERE cliche_pk = 3) Group c.cliche_pk   

The problem is, as there is one, for the list of all the elements, the subquiri will not have to pay literal value.

I tried this question but it is not working

  select one Cr. *, @cliche: = c.cliche_pk one to cliché c INNER join clich_revioo CR on C.clitch_pack = cr.clitch_pac a WHERE cr.numero = (select MAX (number) fROM cliche_revisao WHERE cliche_pk = @cliche) c by a group. Cliche_pk    

You have the right idea, but you want to use a correlated subquery Are:

  SELECT cr * Clutch C INNER to cliche_revisao cr click on c.cliche_pk = cr.cliche_pk WHERE cr.numero = (The maximum value will be found in the row. C.cliche_pk  

< P>

For each cliche_pk .

No comments:

Post a Comment