tags:

views:

750

answers:

1

Part of the MySQL query that I'm trying to convert to pgSQL :

LEFT JOIN {$_TABLES['comments']} c ON c.sid = concat('fileid_' ,a.lid )

This got messy since it's concatenating a string with a column(a.lid), which isn't supported by the SQL 92 || operator(important!). Any idea's how to redo this part of the query for pgSQL?

+1  A: 

PostgreSQL 8.3 and up supports || operator as long as at least one of the operands is a string. Concatentation of column with string literal works as well. What version are you using?

ChssPly76
Yea I was trying it on an older version.
Stanislav Palatnik
According to the manual, the `||` string concatenation operator is supported on older versions too, such as version 7.4 (the earliest version with online docs).
Bill Karwin
You can always cast the integer one, as in:'file_id' || CAST (a.lid AS text)
Magnus Hagander