Kirjava wrote:I got E in GCSE-ICT.
I have two tables.
Table 1: Films & TV
Title, Format, Location
Table 2: Games
Title, Format, Location
I want a list of everything in any particular place.
Example: Shelf 5
I want one list of everything on Shelf 5.
How do I do that?
Use the following Query:
- Code: Select all Expand viewCollapse view
Select A.* From
(
Select
"Files & TV"."Title",
"Files & TV"."Format",
"Files & TV"."Location"
From "Files & TV"
Where "Files & TV"."Location" = 'Shelf 5'
UNION
Select
"Games"."Title",
"Games"."Format",
"Games"."Location"
From "Games"
Where "Games"."Location" = 'Shelf 5'
) as A
Alternatively, if you want a Query where the user is prompted for the
"Location", use the following Query:
- Code: Select all Expand viewCollapse view
Select A.* From
(
Select
"Files & TV"."Title",
"Files & TV"."Format",
"Files & TV"."Location"
From "Files & TV"
Where "Files & TV"."Location" = :Enter_01_Location
UNION
Select
"Games"."Title",
"Games"."Format",
"Games"."Location"
From "Games"
Where "Games"."Location" = :Enter_01_Location
) as A
Explanation: By using the SQL
UNION statement, it will combine the results as you desire. If you need information about
UNION, please do an Internet Search on
SQL Tutorial UNION.
I hope this helps, please be sure to let me / us know.
Sliderule
Thanks to add
[Solved] in your
1st post Subject (edit button top right) if this issue has been resolved.