R
ryan.fitzpatrick3
I have a union query that pairs up two tables. The first table has a
selection of items where upon selection it'll bring up items in the
2nd table. Some selections in the first table do not bring up items in
the 2nd table simply because they're no items to bring up. This works
fine. What I'd like to do it on my union query is to pull either or
data. The tables are setup in the same format, each has 3 fields, 1 is
autonum, 2 is the item, 3 is how the 2nd table links to the 1st table.
Currently the union pulls both field 2 on both tables and puts it into
one column, which is nice, but then it double counts the item; meaning
lets say I have these selections in table one
table 1:
Fruit
Veg
Nuts
table 2:
apple
orange - for fruits in table 1
grape
walnut
pecan - for nuts in table 1
almond
lets say Veg has no sub categories.
Right now the union will pull all data
fruit, veg, nuts, apple, orange, grape, walnut, pecan, almond, so its
doubling counting fruit and its subclass items. I want it only to
bring up the lowest subclass items, and if there are no subclass items
it'll bring up that class item like Veg (since it has no subclass
item). Is this possible or is there an easier way. Here is my union
code.
SELECT [itemclass].item
FROM [itemclass]
UNION select [itemsubclass].item
from [itemsubclass ];
Thanks in advance,
Ryan
selection of items where upon selection it'll bring up items in the
2nd table. Some selections in the first table do not bring up items in
the 2nd table simply because they're no items to bring up. This works
fine. What I'd like to do it on my union query is to pull either or
data. The tables are setup in the same format, each has 3 fields, 1 is
autonum, 2 is the item, 3 is how the 2nd table links to the 1st table.
Currently the union pulls both field 2 on both tables and puts it into
one column, which is nice, but then it double counts the item; meaning
lets say I have these selections in table one
table 1:
Fruit
Veg
Nuts
table 2:
apple
orange - for fruits in table 1
grape
walnut
pecan - for nuts in table 1
almond
lets say Veg has no sub categories.
Right now the union will pull all data
fruit, veg, nuts, apple, orange, grape, walnut, pecan, almond, so its
doubling counting fruit and its subclass items. I want it only to
bring up the lowest subclass items, and if there are no subclass items
it'll bring up that class item like Veg (since it has no subclass
item). Is this possible or is there an easier way. Here is my union
code.
SELECT [itemclass].item
FROM [itemclass]
UNION select [itemsubclass].item
from [itemsubclass ];
Thanks in advance,
Ryan