Question Locked

SQL Select Statement?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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

VSP Table
Int_VSP_ID VSP_Name
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

5 replies

by darryl~

just do a Google search on joining tables with SQL

by sundayose

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.

by bvukov

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 VSP vs ON vo.Int_VSP_ID = vs.Int_VSP_ID
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

by darryl~

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

Darryl

This discussion is closed to new replies.