Web Development



SQL Select Statement?

By sundayose ·
Voucher Table
V_ID Str_Barcode C_ID Int??_VSP_ID
1 HB001 1 13
2 HB003 2 20

VSP Table
13 Kamukama
20 Bamu

Client Table
C_ID Str_CLientN V_ID
1 Janet B 20
2 Joseph N 15

Village Table
V_ID Str_VillageN
15 Beni
20 Butembo

Distributor Table
D_ID Str_Distributor N V_ID
1 Musa 15
2 John 20

Required Result
Str_Barcode Str_VSPN Str_ClientN Str_VillageN Str_DistributorN
HB001 Kamukama Janet B Beni Musa
HB003 Bamu Joseph N Butembo John

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

That's a standard SQL query

by Darryl~ Moderator In reply to SQL Select Statement?

just do a Google search on joining tables with SQL

Collapse -

Reponse To Answer

by sundayose In reply to That's a standard SQL que ...

Thanks for your advise.

Would please send me the query to come up with a similar as the one indicated. I have already tried Google and failed.

Collapse -

You have some wrong foreign keys in there...

by bvukov In reply to SQL Select Statement?

You must have dome something wrong with the pasting of the data, since client and village are:
Client Table:
1 Janet B 20
2 Joseph N 15

Village Table:
15 Beni
20 Butembo

Your query is:
SELECT vo.Str_Barcode, vs.VSP_Name, cl.Str_CLientN, vi.Str_VillageN, di.Str_DistributorN
FROM Voucher vo
INNER JOIN Client cl ON vo.C_ID = cl.C_ID
INNER JOIN Distributor di ON cl.V_ID = di.V_ID
INNER JOIN Village vi ON cl.V_ID = vi.V_ID

Collapse -

Now you went & done his homework....

by Darryl~ Moderator In reply to SQL Select Statement?

Hahahaha.......I was trying to avoid that.


Related Discussions

Related Forums