in reply to Re: speeding up mySQL query in .pm
in thread speeding up mySQL query in .pm

Unless mySQL and T-SQL (what's T-SQL?) are very different from Oracle, I think you mean this:
SELECT DISTINCT min(tmp.escore) as escore, tmp.org_id FROM ( SELECT id2, escore, org_id2 FROM blast, protein WHERE id1 = id AND text_id = ? UNION SELECT id1, escore, org_id1 FROM blast, protein WHERE id2 = id AND text_id = ? ) tmp GROUP BY tmp.org_id
If I knew what columns belonged to which tables I might be able to offer more advice - without that information, I get a headache every time I try to visualize what's going on here...
Update
With the WHERE EXISTS, you end up selecting from the original blast and protein tables if the subselect returns any rows, when what you want to do is select from the subselect results.

Replies are listed 'Best First'.
Re: Re: Re: speeding up mySQL query in .pm
by monktim (Friar) on Aug 15, 2003 at 13:46 UTC
    Good call bean. Your query is more succinct. I cast you a vote :). T-SQL = Transact-SQL = MS flavor of SQL in MS SQL Server.

    Anonymous Monk: is sounds like you need to put a use DBI; at the top of your program. Since you're a self proclaimed novice you make want to check this out Before asking a database related question .... It's a great read.

    Good luck.