Question Locked

How to write SQL Multiple Selection statement?

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

I have three table in my database as shown below

Voucher Table
V_ID Str.Barcode C_ID
1 HB001 1
2 HB003 2

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

Village Table
V_ID Str_VillageN
15 Beni
20 Butembo

I need to get a result like this
HB001 Janet B Beni
HB003 Joseph N Butembo

Thanks for your contribution.

3 replies

by john.a.wills

I am assuming that "Str.Barcode" should be "Str_Barcode" and that you have the village names interchanged in your example output.
SELECT Str_Barcode,
St_ClientN,
Str_VillageN
FROM Voucher LEFT JOIN Client ON Voucher.C_ID = Client.C_ID
LEFT JOIN Village ON Client.V_ID = Village.V_ID;

This discussion is closed to new replies.