i have 4 tables and i need to join it (1 Viewer)

mansour el beainy

New member
Local time
Today, 08:45
Joined
Jun 10, 2013
Messages
2
HELLO DEAR,

all of this tables have (model) as primary key
table1 named products (maker,model,type)
table2 named pc (model,speed,ram,price)
table3 named laptop (model,speed ram,speed,screen,price)
table4 named printer (model,color,type,price)

the question is :
find the model number and price of all products manufactured by maker = "D"

CAN SOMEONE HELP ME TO SOLVE THIS
ITS A PART OF A SMALL PROJECT AT UNIVERSITY
BEST REGARS
 

recyan

Registered User.
Local time
Today, 16:15
Joined
Dec 30, 2011
Messages
180
Am a bit confused.
Why do we have 4 tables with the same primary key?
Why not a single table ?

Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 11:45
Joined
Nov 30, 2011
Messages
8,494
I second recyan.. Also some of your table have similar information repeated.. Could you explain?
 

mansour el beainy

New member
Local time
Today, 08:45
Joined
Jun 10, 2013
Messages
2
hello dear all
i'm very thankful for your fast reply :D
my doctor at university gave me a project to force me to learn how to create table and queries and report and design on access
because i'm studying DATABASE.
So that why it wasn't in same table
PS. THE PRICE AND SPEED ARE SPECIAL FOR EACH TABLE (EVERY LAPTOP HAVE A SPEED DIFFERENT OF THE SPEED OF A PC ,SO THAT WHY I HAVE SIMILAR INFORMATIONS
any way i solved this query
it was to make union between all table
and there is the result
QUERY ONE :
SELECT Products.MAKER, Products.MODEL, PC.PRICE
FROM PC INNER JOIN Products ON PC.MODEL=Products.MODEL
WHERE (((Products.MAKER)="d"));
QUERY TWO:
SELECT DISTINCT Products.MAKER, Products.MODEL, LAPTOP.PRICE
FROM LAPTOP INNER JOIN Products ON LAPTOP.MODEL = Products.MODEL
WHERE (((Products.MAKER)="d"));
QUERY THREE:
SELECT Products.MAKER, PRINTER.MODEL, PRINTER.PRICE
FROM Products INNER JOIN PRINTER ON Products.MODEL = PRINTER.MODEL
WHERE (((Products.MAKER)="d"));
THAN I MADE A QUERY WHICH UNION ALL THOSE QUERIES
SELECT [model],[price]
FROM [query1]
WHERE [maker] ="D"

UNION SELECT [model],[price]
FROM [query2]
WHERE [maker]= "D"

UNION SELECT [model],[price]
FROM [query3]
WHERE [maker]= "D";
-----------------------
THAN THE NEW TABLE IT APPEAR
MAKER-MODEL-PRICE :D
-------------------------
THANKS YOU ALL DEAR
 

Users who are viewing this thread

Top Bottom