Jump to content


Photo

Select Max(date_tarif) Result Problem


  • Please log in to reply
17 replies to this topic

#16 peterlaursen

peterlaursen

    Advanced Member

  • Admin
  • PipPipPip
  • 8,148 posts
  • Gender:Male
  • Location:Skagen, Denmark

Posted 16 August 2006 - 10:08 AM

It is true that subselects can be slow, if it results in large temporary tables.
However this temporary tables has only 5 rows!

I data shall be SYNC'ed with SQLyog it is not alwas a good idea to have a auto-icrement PK.
Even the 'smartest' database experts disagree on that!

I think you coul JOIN the table to itself as well.
One day when I get the time I will study joins in details!

I think the issue here is the SCHEMA itself. When there is so much troubl with a query it often indicates that the SCHEMA design is not optimal! I think it was an option to have data in two InnoDB tables related with Foreign Keys - but I do not fully understand the data.

The reason the my proposal did not work was because of the max() aggregate function. Int would have worked with count().
Computers make your grey hair come off ....

Peter Laursen
Webyog

#17 TomBez

TomBez

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • Location:Austria

Posted 16 August 2006 - 01:06 PM

I data shall be SYNC'ed with SQLyog it is not alwas a good idea to have a auto-icrement PK.
Even the 'smartest' database experts disagree on that!

Maybe it is because I had to often build a lot of functionality around a natural key which didn't worked as designed, sometimes the real world changes, so that adoptions in den schema itself have to made, with surrugate keys less of them have to be made, but thats only my experience.

I think you coul JOIN the table to itself as well.
One day when I get the time I will study joins in details!

I'm not sure if mysql supports selfreferencing like oracle. i haven't found any "connect by" clause in the documentation. a statement like "select mytable1.* from mytable mytable1, mytable mytable2 where mytable1.column1>10 and mytable2.column1<3" is possible and works

#18 Lorrinesr

Lorrinesr

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 27 March 2017 - 07:47 PM

Hey, thanks for the post.Thanks Again. Will read on... Desjarlais




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users