Trying to concatinate strings in WHERE clause

Hutch619

New Member
Why am I not allowed to concatinate strings in a WHERE clause? Is this not possible?

Code:
[COLOR="Blue"]SELECT[/COLOR]
   i."Inventory-Item-ID",
   i."Inventory-Item-Desc",
   '[COLOR="DarkOrchid"]Works[/COLOR]' + '[COLOR="DarkOrchid"]Fine[/COLOR]' + '[COLOR="DarkOrchid"]Here[/COLOR]'
[COLOR="DarkRed"]FROM[/COLOR]
   PUB."InventoryItem" AS i 
[COLOR="DarkRed"]WHERE[/COLOR] 
   i."System-ID"='PP' [COLOR="lime"]AND[/COLOR] 
   i."Cust-ID"='4601' [COLOR="lime"]AND[/COLOR] 
   i."Inventory-Item-ID" [COLOR="Lime"]LIKE[/COLOR] '[COLOR="DarkOrchid"]But[/COLOR]' + '[COLOR="DarkOrchid"]Not working[/COLOR]' + '[COLOR="DarkOrchid"]In WHERE clause[/COLOR]'

Here's my error:
Syntax error in SQL statement at or about \"+ 'Not working' + 'In WHERE clause'\" (10713)

Progress Version: Openedge 10.1B
 
AND is not a concatenation operator.

It is not being used as one, is it?

Why am I not allowed to concatinate strings in a WHERE clause? Is this not possible?

Code:
[COLOR="Blue"]SELECT[/COLOR]
   i."Inventory-Item-ID",
   i."Inventory-Item-Desc",
   '[COLOR="DarkOrchid"]Works[/COLOR]' + '[COLOR="DarkOrchid"]Fine[/COLOR]' + '[COLOR="DarkOrchid"]Here[/COLOR]'
[COLOR="DarkRed"]FROM[/COLOR]
   PUB."InventoryItem" AS i 
[COLOR="DarkRed"]WHERE[/COLOR] 
   i."System-ID"='PP' [COLOR="lime"]AND[/COLOR] 
   i."Cust-ID"='4601' [COLOR="lime"]AND[/COLOR] 
   i."Inventory-Item-ID" [COLOR="Lime"]LIKE[/COLOR] '[COLOR="DarkOrchid"]But[/COLOR]' + '[COLOR="DarkOrchid"]Not working[/COLOR]' + '[COLOR="DarkOrchid"]In WHERE clause[/COLOR]'

Here's my error:
Syntax error in SQL statement at or about \"+ 'Not working' + 'In WHERE clause'\" (10713)

Progress Version: Openedge 10.1B

Like most others here, I am not an SQL developer, but the 'But' seems to be indicated as a terminator in your error message. I know this is not consistent with the SELECT clause above where you prove it works, but does it work when the string is put in brackets, or SQL equivalent?

ie.
Code:
i."Inventory-Item-ID" LIKE ('But' + 'Not working' + 'In WHERE clause')

also, try proving with
Code:
i."Inventory-Item-ID" LIKE 'But Not working In WHERE clause'
 
Incidentally, on my quick (and admittedly ignoramus) reading of SQL-92 LIKE syntax, the implied runtime parsing of the LIKE clause (beyond the standard pattern matching characters) is invalid, so your separation of the string pattern using "+" would seem moot.
 

Wogjoift73

New Member
You will help the optimizer if you provide it with all possible WHERE clause conditions.SELECT FROMa, b, cWHERE a.key = b.key AND b.key = c.key ANDa.key = c.key
 
Top