You can use IN to create subqueries. For example:

SELECT tickets.id
FROM tickets
WHERE tickets.id IN (
    SELECT tickets.id
    FROM tickets
    WHERE tickets.ref LIKE 'AAAA-%'
)

Published: 23/03/2018

Last updated: 22/05/2018