Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Problem with database under Win32

by runrig (Abbot)
on Nov 22, 2003 at 10:03 UTC ( #309143=note: print w/replies, xml ) Need Help??


in reply to Problem with database under Win32

Depending on the uniqueness of the id field in table1, and how close your real problem is to this example, but maybe this would work:
select table2.* from table1, table2 where table1.id = table2.id order by id desc
And fetch until id changes. And I don't know if DBI would help either, but if you have to rewrite the bits that don't work anyway, and if DBI does work, I'd consider that as an option. DBD::Sybase supports multiple result sets (and it supports SQL Server to some extent), I don't know if that is what you are referring to, or if that's applicable here.

Replies are listed 'Best First'.
Re: Re: Problem with database under Win32
by NetWallah (Canon) on Nov 23, 2003 at 16:47 UTC
    Using SELECT TOP 1 From ..... ORDER BY ID DESC may be faster than trying a "Max".

    I am not a SQL weenie though - you may want to check with your DBA as to why the subquery seems "slower".

      I am not sure - if you MAX() an index, you usually get top performance with no disk access at all; in any other case you need a table scan to know all the values, so you can max() them. My actual query is not any way similar to the one I am presenting here (it's a five-page belemoth, just in the case you wonder, even with all repeated subqueries extracted!)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://309143]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-01-26 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?