Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: MySQL question

by shadox (Priest)
on Mar 28, 2002 at 21:51 UTC ( #155126=note: print w/replies, xml ) Need Help??


in reply to MySQL question

If i understand you well ( i am half asleep ), what you want is a list of titles with the greatest version.
Something like this
+-------+---------+---------+ | title | doc_num | version | +-------+---------+---------+ | bar | 1234 | 9 | | foo | 1234 | 7 | | other | 2121 | 7 | +-------+---------+---------+
Well if it is right, all what you need is to change your ORDER BY, for a GROUP by.
SELECT title, doc_num, MAX(version) AS version from test GROUP BY titl +e; # For this example "test" is the table name


Failure is not an option - it is a privilege reserved for
those who do not try hard enough.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://155126]
help
Chatterbox?
[Corion]: ... that balance, and when. And it seems to me that they somehow really messed up the database since the start of the year and have been frantically adding and subtracting numbers from the totals, but without trace ;)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2018-01-23 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (249 votes). Check out past polls.

    Notices?