My SQL command keeps failing whenever I try to implement a JOIN claus. It will successfully output the fields when executing a simple “SELECT * FROM TABLE_NAME”. I’m not sure where I am going wrong on this as I am new to working with databases.
https://i.sstatic.net/v8gGMBlo.png
My aim is to to try output the fields “SongNameEN”, “Composer”, “SongSource”, “LocationName”. However, I keep getting the output:
https://i.sstatic.net/7ATqqX5e.png
I don’t believe there is anything wrong with the code to connect the database as that works with simple commands.
public static void SelectQuery(OleDbConnection connection) {
string command = @"
SELECT
SongList.SongNameEN,
SongList.Composer,
SongList.SongSource
FROM
(SongLocation
INNER JOIN SongList ON SongLocation.SongID = SongList.SongID)
WHERE
SongLocation.LocationID = 5";
OleDbCommand sqlCommand = new OleDbCommand(command, connection);
OleDbDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read()) {
Console.WriteLine($"{reader["SongID"]} | {reader["SongNameEN"]} | {reader["Composer"]} | {reader["Source"]}");
}
}