Let's say we have a database with a table defined by the following fields:
id -- localCode -- localNumber -- status
SELECT localCode, localNumber FROM Table WHERE status = 'val_1'
Make a self-join on the table.
SELECT t2.id FROM Table t1 INNER JOIN Table t2 ON t1.localCode = t2.localCode AND t1.localNumber = t2.localNumber WHERE t1.status = 'val_1' AND t2.status = 'val_2'
This query will find all IDs of records that have status
val_2 and where a corresponding entry with status