Mysql, Getting all rows in which field ends in a specific character, and another field exists that is the same but doesn't end in that character
How about this : 

select t1.key 
from table1 t1 
inner join table1 t2 
      on   t1.key = t2.key || 'P' 
where t1.key like '%P' 
order by t1.key ; 


Querying t1 gives you a list of all of the rows with keys that end in 'P'. 

The join to t2 is based on rows where t2's key, plus a trailing 'P', matches the key in t1  (or, alternatively, the original key without the trailing 'P').