Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

•Re: Re: Re: MySQL question

by merlyn (Sage)
on Mar 28, 2002 at 22:28 UTC ( #155138=note: print w/replies, xml ) Need Help??


in reply to Re: Re: MySQL question
in thread MySQL question

Ahh. Then again, with a real database with subselects, that'd be:
SELECT title, doc_num, version FROM atable WHERE (doc_num, version) IN ( SELECT doc_num, MAX(version) FROM atable GROUP BY doc_num );
Again, this won't work in puny MySQL. PostgreSQL or better, baby!

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: Re: Re: MySQL question
by rbc (Curate) on Mar 29, 2002 at 17:10 UTC
    If Kozz cannot upgrade to PostgreSQL for some reason couldn't Kozz ape a subselect with by creating a tempory table "ttable" and then join "atable" with that? sonething like this ...
    create table ttable as SELECT doc_num, MAX(version) FROM atable GROUP BY doc_num; SELECT title, doc_num, version FROM atable a, ttable t WHERE a.doc_num = t.doc_num and a.version = t.version;

    ... I don't know about the other monks I find SQL
    fun like its a weird puzzle.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://155138]
help
Chatterbox?
[choroba]: I mean I haven't used DBIx::Class nor M:S, only Moo
[1nickt]: Haha, I was learning about Linux filesystem trees trying to understand how Moo fits.
[1nickt]: I just got my feet wet with some DBIC coding this last week. I feel "meh" about it so far. It was pretty easy to add a sub to the DBIC class to filter search results ...
[1nickt]: ... in the calling code ... $rs = $rs->maturity(" stable");. But I don;t enjoy feeling that far away from the SQL and the DB, really.
[1nickt]: The same project (CPAN Testers API) is using experimental signatures (and therefore 5.024) ... which is what replaced Method::Signatures , afaict.
[1nickt]: But the new $job is on an older Perl and therefore using M::S, the syntax of which looks clunky to me, so far.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2017-11-24 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (349 votes). Check out past polls.

    Notices?