Re: [SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
For the following query, I have a little problem ... First, I have to rewrite several times the same query because the alias are not recognised in the same query ( I got an error when I try to reuse the alias "nb_bogus_leads", for instance). Do you have a way to avoid this ? Because If I do so, the

Re: [SQL] Error message with a SQL function

2003-08-14 Thread krystoffff
Thanks You were right, it was because of the return void But I think in the documentation, I read somewhere that this kind of return was allowed ... I must have mistaken ... ---(end of broadcast)--- TIP 6: Have you searched our list archives?

Re: [SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
I tried with some LEFT JOINS, which give me the possibility to keep the information of the right table. I have now the following query, which is 10 times faster !!! (from 16s to 1.6s) But I's like to remove the last subquery, to see if it faster ;) Can somebody help me ?

Re: [SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
OK, here is the final query without any subquery ... -- SELECT L. * FROM lead L LEFT JOIN purchase P ON ( L.id = P.lead_id ) LEFT JOIN member_exclusion M ON ( P.member_id = M.member_id_to_exclude ) LEFT JOIN ( SELECT DISTINCT affiliate_locked_id FROM affiliate_lockout W

[SQL] Error message with a SQL function

2003-08-14 Thread krystoffff
ffiliate. Has anybody an idea ? Thanks Krysto ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
are apparently very slow to run, according to what I read), but I can't figure how to rewrite this query without any subquery ... Maybe the problem comes from the index ... How would you create your indexes to optimize this query ? Could somebody help me ? Thanks krysto ---

[SQL] optimisation of a code

2003-08-11 Thread krystoffff
q_members .= " AND $id NOT IN (select lead_id from purchase where member_id IN (select member_id_to_exclude from member_exclusion where member_id=member.id))"; $q_members .= " ORDER BY balance_in_points DESC"; $r_members = mysql_query($q_members); $nbdispo = $NBPERSONS_SH