Using transactions would be rather useless here, since your query only deals with a SELECT
.
There are 2 choices here. (Do note that I've only included the SQL-code.)
1. You can use a SELECT
inside a SELECT
statement.
SELECT active
FROM flags
WHERE id IN (
SELECT id
FROM auth
WHERE alias = 'userinput'
);
2. Other possibility is to use a JOIN
.
SELECT f.active
FROM flags f
INNER JOIN auth a
ON f.id = a.id
WHERE a.alias = 'userinput';
Here, aliases like f
and a
are used to designate the tables.