On 17/10/2013 14:45, Igor Tandetnik wrote:
On 10/17/2013 3:35 AM, dean gwilliam wrote:
On 16/10/2013 22:04, Igor Tandetnik wrote:
On 10/16/2013 4:49 PM, dean gwilliam wrote:
if I have two tables
1 aliases (std_name, raw_name)
2 items (name......)
what would the query look like to select all "name" fields in "itms"
that match neither "std_name" or "raw_name" in "aliases"
and where the resulting list of "name"s contains no duplicates.

select distinct name from items
where not exists (select 1 from aliases where std_name = name or
raw_name = name);

Thank you very much Igor. Your answer is very much appreciated.
It seems that "std_name" would be better placed in another table eg
"std_names" and I'm not sure how you'd change the query to reflect the
extra table

select distinct name from items
where name not in (select std_name from std_names)
and name not in (select raw_name from aliases);

-- or

select distinct name from items
where name not in (
  select std_name from std_names
  union all
  select raw_name from aliases
);

Igor.
Thank you very much indeed!
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to