SQL - Return a field value if it exists, otherwise, return a specific text.
Posted on 2011-10-03
background info, i am trying to create a list view that shows thumbail images, if they have been created (and image name saved in my table).
I'm wonderinig if there is an easy way I can do this, so it works with both access and sql server, so that I can achieve this logic:
Select all my courses from the course list, left joining with my section table, which has the thumbnail image name stored in one column (but may be blank). There is a chance no record is returned from this 2nd table at all.
In the query below, i want Thumbnail's value to be the image name returned, OR "NoThumbnailYet.jpg", if it returns no value.
Select C.Course_Number, S.Thumbnail from Courses C Left JOIN Sections S on C.Course_Number=S.Course_Number Order by C.Course_Number
Is there a basic syntax I should use, or is this something I am better off doing after returning the full query, during building my data table to bind to the list view. I know I can do the manipulating after the fact, just was hoping for a more simple solution.