My mind is drawing a blank. Not sure where to go to find the answer. Here is the statement in C#:
sSQL = "SELECT \"Image_Filename\" FROM \"Instruments\" WHERE ";
To finish off the WHERE clause, I need to look at the first 2 letters, like "D:". My question is how do I specify in the WHERE clause, to look at the first 2 characters in the Image_Filename column? What is the correct SQL syntax for looking at just a portion of a column?
SELECT "Image_Filename" FROM "Instruments" WHERE "ImageFilename" LIKE 'D:%';
It's not clear what kind of test you're trying to apply to those first two characters. If you want to pull them out to use in an expression (e.g., if you want to see if they are greater or less than something else), you can use SUBSTRING or LEFT.
SELECT SUBSTRING('abc' FROM 1 FOR 2),LEFT('abc',2),LEFT('abc',2)<'aa' AS is_less,LEFT('abc',2)>'aa' AS is_more;
substring | left | is_less | is_more
-----------+------+---------+---------ab | ab | f | t
(1 row)