Hi.
My testTable table has two fields (words and current) and looks like this:
words______current
ten_________no
this________yes
half________yes
question____yes
fibber_______no
I want to query the table to find all the words that are "current", like this:
words___
this
half
question
But instead of a result set that has multiple rows, I want all the rows combined into one row, comma separated, like this:
words___________
this, half, question
I dug around and found a post elsewhere that indicated that this would do the trick:
DECLARE @WordList varchar(500)
SELECT @WordList = COALESCE(@WordList + ', ', '') + testTable.words
FROM testTable
WHERE testTable.current = 1
SELECT @WordList
I don't really understand this much. When I try to run it in Access, I get this error:
"Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
And when I click OK, Access highlights the first line of the SQL (my DECLARE statement).
Can anyone help me out with this?
Thanks,
Duluter
My testTable table has two fields (words and current) and looks like this:
words______current
ten_________no
this________yes
half________yes
question____yes
fibber_______no
I want to query the table to find all the words that are "current", like this:
words___
this
half
question
But instead of a result set that has multiple rows, I want all the rows combined into one row, comma separated, like this:
words___________
this, half, question
I dug around and found a post elsewhere that indicated that this would do the trick:
DECLARE @WordList varchar(500)
SELECT @WordList = COALESCE(@WordList + ', ', '') + testTable.words
FROM testTable
WHERE testTable.current = 1
SELECT @WordList
I don't really understand this much. When I try to run it in Access, I get this error:
"Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
And when I click OK, Access highlights the first line of the SQL (my DECLARE statement).
Can anyone help me out with this?
Thanks,
Duluter