MySQL Forums
Forum List  »  Newbie

Re: Trouble making formula.
Posted by: Peter Brawley
Date: May 02, 2016 02:31PM

?! Where's the result of Show Create Table?

...select a.points between 1 and 7... returns 1 for rows where 1<=points<=7, otherwise 0. It does not exclude rows where points are outside that range. For that you need a WHERE clause. Read about WHERE clauses in the manual. AS you describe your requirement, your Where clause needs to restrict the result to rows where ...

(i) 1 <= points <= 7

(ii) date = (select max(date) from data)

Can you write that Where clause?

Once you have a row set meeting those conditions, you need to pick off the rows with the top 7 points values. Look up Order By and Limit in the manual.

Finally, you need to join these results to player names in the players table. Your query does that, but badly. MySQL joins should be written with explicit join syntax, for example

...from data a join players b using(playersid)...

rather than with the comma join syntax you used.

Try implementing those notions, and let's see what you come up with.

Options: ReplyQuote


Subject
Written By
Posted
May 02, 2016 07:26AM
Re: Trouble making formula.
May 02, 2016 02:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.