Re: SQL syntax - Mailing list pgsql-general

From Adrian Klaver
Subject Re: SQL syntax
Date
Msg-id 8be3c025-ebf8-59f4-1ab8-22206947e078@aklaver.com
Whole thread Raw
In response to SQL syntax  (Dale Seaburg <kg5lt@verizon.net>)
Responses Re: SQL syntax  (Ken Tanzer <ken.tanzer@gmail.com>)
Re: SQL syntax  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: SQL syntax  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-general
On 03/02/2018 04:36 PM, Dale Seaburg wrote:
> 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:%';

If you want case insensitive then ILIKE. For more info:
https://www.postgresql.org/docs/10/static/functions-matching.html#FUNCTIONS-LIKE

> 
> I feel so dumb...  This can't be that hard, but I am exhausted and 
> running out of ideas.  I need someone to give me a boost!  ;-)
> 
> Thanks,
> Dale.
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Dale Seaburg
Date:
Subject: SQL syntax
Next
From: Ken Tanzer
Date:
Subject: Re: SQL syntax