mercredi 23 mars 2016

SQL SELECT from two tables to set a variable in the select statement

I have two tables:

alerts {id, title, description}

read_alerts {alert_id}

i want to execute a sql that returns the following:

alerts {id, title, description, is_read}

The is_read needs to be 1 or 0. 1 if the id is set in read_alerts, 0 otherwise.

What would be the best approach to achieve this in one sql query?

I am using Sqlite

Aucun commentaire:

Enregistrer un commentaire