Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Statement help!

Status
Not open for further replies.

ColdFusionKing

Programmer
Dec 5, 2002
145
GB
I was wondering if the SQL gurus out there could help. I have this table that keps a log
of the user search activity. For ex, on the site search page of the site, if a user searches for
a keyword "test", it gets stored on the database table along with other details like the
username, date/time, search category and the results found.
The columns are
DateTime, UserName, SearchKeyword, SearchCategory and ResultsFound

I am displaying this information in a report to the admin user.

It currently displays all the information using a simple select statement. I want to
display all search keywords a user has searched for in one row.
So instead of displaying the information like this
09/09/2003 17:41:26 powerpoint testUser1
09/09/2003 18:42:26 word testUser1
09/09/2003 19:44:26 excel testUser1
09/09/2003 20:45:26 notepad testUser1

I want to display it like this
In the last 7 days powerpoint,word,excel,notepadtestUser1

Can somebody show me how to do this please
Best Regards
Allan
 
"I want to display all X in one row."

next to impossible to do in SQL, almost trivial to do with the GROUP= paramater of CFOUTPUT

run your normal query to select the user's keywords, and make sure the query included ORDER BY userid

then

<CFOUTPUT query=&quot;foo&quot; GROUP=&quot;userid&quot;>
In the last 7 days:
<CFOUTPUT>
#keyword#,
</CFOUTPUT>
#userid#
</CFOUTPUT>


rudy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top