Rows locked by another process

This technical problem deals with how to write a SQL query that returns rows from a table that have been locked by another process.

Problem

Write a SQL query that returns the rows from a table that have been locked by another process.
Example input:
Table:
id | name | locked
1 | John | 0
2 | Jane | 1
3 | Joe | 0
Example output:
2 | Jane | 1

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT * FROM table WHERE locked = 1;

/*

The above solution is optimal because it is the most efficient way to return the rows that have been locked.

*/

A.I. Evaluation of the Solution

The solution correctly returns the rows that have been locked. However, it is not the most efficient solution. A more efficient solution would be to use a subquery.

Evaluated at: 2022-11-05 01:15:27