MYSQL Query issue with incorrect output -
hi have following query :
$query = "select distinct registration, series, operator, msn, ln, model, status, pic, piccopy (select * (select * history status = 'active' order date asc) group ln) a2 group msn order ln asc";
this works - kind of.... see here
its listing airframes have been or active. need list active airframes. because airframe scrapped or put museum example - classed no longer active - e.g. preserved, same may scrapped, above query still sees active. can prevent showing aircraft may falling 1 of following categories:
- grounded
- scrapped
- parted out
- written off
- missing
- stored
- preserved
however grounded /stored/preserved airframe may returned service , become active again, needs find latest "active" , display if not been withdrawn after date.
im guessing simple grabs records airframe eg et-aop, , selects last (latest date aka newest date) sees if active , if displays it, if not wont. how do this, driving me mental
since don't have table scheme, i've writing best guess.
this history table:
history_id plane_id status (active, grounded, missing etc.)
selecting planes 'active' latest status:
select plane_id history history_id in ( select max(history_id) history group plane_id ) , status = 'active'
Comments
Post a Comment