I'm trying to build a comma-separated list of values out of a field in Oracle.
I find some sample code that does this:
DECLARE @List VARCHAR(5000)
SELECT @List = COALESCE(@List + ', ' + Display, Display)
FROM TestTable
Order By Display
But when I try that I always get an error about the FROM keyword not being were it was expected. I can use SELECT INTO
and it works but if I have more than one row I get the fetch error.
Why can't I do as follows:
SELECT myVar = Field1
FROM myTable
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…