On Wed, 2014-09-24 at 06:13 -0600, Keith Medcalf wrote:
> Would it not be more efficient to skip the join altogether since all
> you want is the list of uid's, and assuming that you have maintained
> the referential integrity of your database mail_list(list_uid)
> references main(uid)?
> SELECT list_uid 
>   FROM mail_list
>  WHERE email LIKE 'al%'
> SELECT uid
>   FROM main 
>  WHERE first_name LIKE 'al%'
>     OR last_name LIKE 'al%';

Yes, but only because I oversimplified. In fact my queries are actually
after *other* fields from the main table. It's just that I'd elided
those fields from the example.

For the sake of the example, please assume my queries were actually
 'SELECT DISTINCT main.uid, main.first_name, main.last_name FROM …'

The real-life query that this is simplified *from* is discussed at

sqlite-users mailing list

Reply via email to