Click here to Skip to main content
15,562,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys,
I have this 5 tables:

CPU: BRAND, MODEL, ID_CPU, SOCKET, TYPE, WARRANTY, SOLD AND CHECKOUT

DISK: BRAND, MODEL, ID_DISK, STORAGE, TYPE, DIMENSIONS, WEIGHT, WARRANTY, SOLD AND CHECKOUT

DESKTOP: BRAND, MODEL, ID_DESKTOP, MOTHERBOARD, CPU, GRAPHICS, MEMORY, STORAGE, POWERSUPPLY, OS, DIMENSIONS, WEIGHT, WARRANTY, SOLD AND CHECKOUT

NOTEBOOK: BRAND, MODEL, ID_NOTEBOOK, MOTHERBOARD, CPU, GRAPHICS, MEMORY, STORAGE, POWERSUPPLY, OS, DIMENSIONS, WEIGHT, WARRANTY, SOLD AND CHECKOUT

RAM: BRAND, MODEL, ID_RAM, MEMORY, TYPE, DIMENSIONS, WEIGHT, WARRANTY, SOLD AND CHECKOUT

And I want to select all this information from all 5 tables but filtering by CHECKOUT, meaning this value is either 0 our 1 and show on checkout table.

PS: I'm using ACCESS DATABASE. It's a school project.

What I have tried:

Tryied to use the string "SELECT * FROM CPU,RAM,NOTEBOOK,DESKTOP,DISK WHERE CHECKOUT = 1"
Posted
Updated 29-Mar-17 3:46am

1 solution

I have already answered this question - How do I filter from 5 diferent tables using one datagridview and tabcontrol[^]

You seriously need to change your database schema!

Because of your awful table design (see my previous response) you will need to use UNION[^]

SQL
SELECT * FROM CPU WHERE CHECKOUT = 1
UNION
SELECT * FROM RAM WHERE CHECKOUT = 1
UNION 
SELECT * FROM NOTEBOOK WHERE CHECKOUT = 1
UNION
SELECT * FROM DESKTOP WHERE CHECKOUT = 1
UNION
SELECT * FROM DISK WHERE CHECKOUT = 1

If you had followed my earlier advice then this would have been
SQL
SELECT * FROM Hardware WHERE CHECKOUT = 1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900