On 8 July 2011 16:37, Dmitry Ruban <[email protected]> wrote:
> Could  you please post here the result of the following query:
>
> select
> child.id as id, pm.start as s1, membership.start as s2,
> ifnull(pm.start,membership.start) as s3 from organisation
> child
> left join organisation pmorg on child.parent_organisation_id=pmorg.id
> left join membership on child.id=membership.organisation_id
> left join membership pm on pmorg.id=pm.organisation_id
>
> where child.id in (1,3) and
> coalesce(pm.start,membership.start) is not null and
> ((membership.active=1 and membership.amount_paid>  0.00 ) or
> (pm.active=1 and pm.amount_paid>  0.00))
>

+----+---------------------+---------------------+---------------------+
| id | s1                  | s2                  | s3                  |
+----+---------------------+---------------------+---------------------+
|  1 | NULL                | 2009-02-24 00:00:00 | 2009-02-24 00:00:00 |
|  1 | NULL                | 2009-07-01 00:00:00 | 2009-07-01 00:00:00 |
|  1 | NULL                | 2010-07-01 00:00:00 | 2010-07-01 00:00:00 |
|  1 | NULL                | 2011-07-01 00:00:00 | 2011-07-01 00:00:00 |
|  3 | 2009-02-24 00:00:00 | NULL                | 2009-02-24 00:00:00 |
|  3 | 2009-07-01 00:00:00 | NULL                | 2009-07-01 00:00:00 |
|  3 | 2010-07-01 00:00:00 | NULL                | 2010-07-01 00:00:00 |
|  3 | 2011-07-01 00:00:00 | NULL                | 2011-07-01 00:00:00 |
+----+---------------------+---------------------+---------------------+

I need rows 4 and 8. As I said, my original query works fine actually ;)

Jochen

-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to