silverblatt
New member
- Local time
- Today, 07:02
- Joined
- Apr 9, 2024
- Messages
- 4
I'm using the SQL shown below to query a simple Access database. When I start a new query in that database, paste the SQL code into SQL view and then run the query, it performs as expected, i.e., it returns all the records where the string "red" appears anywhere in any of the three columns referenced in the WHERE clause. So far, so good. However, when I use the identical query in a VB.Net 2017 application, it returns 0 records but does not throw any exceptions. When I remove the WHERE clause in the VB.Net application, the query returns all records as expected.
How can I resolve this inconsistency? What I want to do is have the query work the same way in the VB.Net application as it does in a native Access query.
How can I resolve this inconsistency? What I want to do is have the query work the same way in the VB.Net application as it does in a native Access query.
SQL:
SELECT Max(Artist.ArtistID) AS ArtistID, Max(Artist.ArtistName) AS ArtistName, Song.SongID,
Max(Song.SongTitle) AS SongTitle, Max(Song.Deprecated) AS Deprecated, Max(Played.PlayDate) AS LastPlayed
FROM ((Artist INNER JOIN Song ON Artist.ArtistID = Song.ArtistID)
LEFT OUTER JOIN Played ON Song.SongID = Played.SongID)
LEFT OUTER JOIN SongAttribute ON Song.SongID = SongAttribute.SongID
WHERE ((Artist.ArtistName LIKE '*red*') OR (Song.SongTitle LIKE '*red*') OR (Song.Comments LIKE '*red*'))
GROUP BY Song.SongID
ORDER BY Max(Artist.ArtistName), Max(Song.SongTitle), Max(Played.PlayDate)