Reputation: 16906
I am trying to display all the names from the table vocabulary
where the vid
s do not match a vid
in collapse_menu
. How would I do this?
Table vocabulary
vid name
1 Sections
2 Posts
6 Forums
5 Departments
13 Free Tags
8 Committees
9 Training and Workshops
10 Policies
12 Projects
14 Teams
Table collapse_menu
vid
8
5
10
Upvotes: 1
Views: 7782
Reputation: 1740
select name
from vocabulary as v,
collapse_menu as c
where v.vid!=c.vid
Edit: Sorry, didn't read the question properly.
Upvotes: -2
Reputation: 8040
I assume that you are asking for the those names in vocabulary, where the vid is not in the collapse_menu table.
In which case
SELECT name
FROM vocabulary
LEFT JOIN collapse_menu ON vocabulary.vid = collapse_menu.vid
WHERE collapse_menu.vid IS NULL
Upvotes: 13
Reputation: 320
SELECT * FROM vocabulary, collapse_menu WHERE vocabulary.vid <> collapse_menu.vid;
Upvotes: 1
Reputation: 15513
select name from vocubulary where vid not in (select vid from collapse_menu)
Upvotes: 4