Nishan Fernando Nishan Fernando - 1 month ago 6
Vb.net Question

SQL selection of multiple tables

A database which stores currency conversion values. These values will be added to text boxes according to the input date in a vb.net program.

Given the three tables

GBP (table)
Date (pk)
GUSD
GEUR

USD(table)
Date (pk)
UGBP
UEUR

EUR(table)
Date (pk)
EUSD
EGBP


How can i select all the records from all 3 tables excluding the Date?

I've managed to select records from one table.

Dim sql As String = "SELECT TOP 1 GEUR,GUSD FROM GBPtb WHERE Date= ?"


Design view of the application

Answer

With the limited information you provided, I'm guessing you might want something like the following

SELECT 1.0 as GBP, GUSD as USD, GEUR as EUR FROM GBP WHERE Date = ?
UNION ALL
SELECT UGBP as GBP, 1.0 as USD, UEUR as EUR FROM USD WHERE Date = ?
UNION ALL
SELECT EGBP as GBP, EUSD as USD, 1.0 as EUR FROM EUR WHERE Date = ?