Solved

Show multiple records in one field using SQL

Posted on 2007-04-03
3
169 Views
Last Modified: 2010-03-19
I'm running an Access front end and a SQL backend.  I have tblDaily and tblRooms.  There is a one to many relationship.  The fields in tblDaily can have multiple rooms.  I want to display 3 fields (Facility, Elevation and Area) from tblDaily but also the multiple rooms from tblRooms all in one field on a report.
Ex: Facility, Elevation, Area, Rm1, Rm2, Rm3

I found Function fncConcat() example code on Expert Exchange but it doesn't work for me because my backend is SQL Server.  Can anyone offer any other suggestions?  Please?
0
Comment
Question by:BobRosas
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
dready earned 500 total points
Comment Utility
I am not sure wether this will work, but give this a try

select facility, elevation, area, (select concat(rooms) from tblRooms where FID_Daily = tblDaily.id) from tblDaily

(Dont know what your tblRooms looks like, i assumed it has a rooms field and a foreign key called FID_Daily... of course you will have to replace it with real fieldnames)
0
 

Author Comment

by:BobRosas
Comment Utility
I could really use more help with the SQL statement.  I forgot to include tblTestPerformed which links tblDaily and tblRooms.  Also tblWorkRelease has the field “facility” which I need.  
The following is the SQL code I’m trying but I get the error “Syntax error in query expression ‘(select concat (tblRooms.RoomNo))’.  

SELECT tblWorkRelease.Facility, tblDaily.Elevation, tblDaily.Area, (select concat (tblRooms.RoomNo))
FROM ((tblWorkRelease INNER JOIN tblDaily ON tblWorkRelease.WorkReleaseId = tblDaily.WorkReleaseId) INNER JOIN tblTestsPerformed ON tblDaily.QCReportNo = tblTestsPerformed.QCReportNo) INNER JOIN tblRooms ON tblTestsPerformed.TestDescId = tblRooms.TestDescId
WHERE (((tblDaily.QCReportNo)=2947))
ORDER BY tblRooms.RoomNo;
Thanks!
0
 

Author Comment

by:BobRosas
Comment Utility
I don't think concat works with SQL but I appreciate that you responded.  I will try reposting my question.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now