Skip to content
Advertisement

Get a group of records by last unknown id

I have a log table where I want to select the entries for a specific group of records that are grouped by an id I don’t know.
See the table below, there are more columns but these are not relevant for the question.

I want to get the last entries of one process for one device
When I query something like this I get all the records of the device:

How can I only get the records with processId 540 in one query when I don’t know the processId is 540?

I already tried it with a subquery:

But MariaDB doesn’t accept LIMIT in a subquery

Advertisement

Answer

Use =:

You only need IN if the subquery is going to return multiple rows.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement