mysql - Choosing one row over another, but not based on the where clause -
not quite sure how ask properly, perhaps part of problem. there exists database many similar records differentiated column called 'priority'. i'd grab record higher priority has same 'type' & 'project' id. example, table looks this:
id project_id type_id priority 1 66 14 0 2 66 14 10 3 66 16 0
currently program selects via project , type:
select * table project_id = 66;
and loops through results , discards lower priority record when there exists multiple records of same type_id
. there way via select?
the ideal result set be:
id project_id type_id priority 2 66 14 10 3 66 16 0
where discarded lower priority type_id 14 record. there may more 2 items same type_id in table.
select * table group project_id, type_id order priority desc
Comments
Post a Comment