The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: RE: FM sender with DDAR


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] SQL question


  • To: ukha_d@xxxxxxx
  • Subject: Re: [OT] SQL question
  • From: "Mark Pollock" <pollocmc@xxxxxxx>
  • Date: Wed, 11 Jul 2001 11:36:32 -0000
  • Delivered-to: rich@xxxxxxx
  • Delivered-to: mailing list ukha_d@xxxxxxx
  • Mailing-list: list ukha_d@xxxxxxx; contact ukha_d-owner@xxxxxxx
  • Reply-to: ukha_d@xxxxxxx

A bit more involved (and I don't know if performance will be an issue)
but here goes.

You need t  create a function e.g.

Public Function concat(CompanyID As Integer) As String
Dim db As Database
Dim rs As Recordset
Dim sTemp
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT EMPLOYEENAME FROM [TABLE B] WHERE
[COMPANY ID] = " & CompanyID)

While Not rs.EOF
sTemp = sTemp & rs!EMPLOYEENAME & ","
rs.MoveNext
Wend
sTemp = Left(sTemp, Len(sTemp) - 1) ' drops the last comma
concat = sTemp
End Function

Then you create a query like this

SELECT [Table A].[Company Name], concat([Table A].[ID]) AS Expr1
FROM [Table A];

And bob's your uncle...

There may be a neater way of doing this but neatness was never my
strongpoint :)

Mark.
--- In ukha_d@y..., "James Hoye" <james.hoye@s...> wrote:
> > SELECT [Table A].[Company Name], First([Table B].EmployeeName) AS
> > FirstOfEmployeeName
> > FROM [Table A] INNER JOIN [Table B] ON [Table A].ID = [Table
> > B].[Company ID]
> > GROUP BY [Table A].[Company Name];
>
> Taking the example one step further, is it possible t  concatenate
all of
> the 'many' records ont  the one row with a separator?
>
> CompanyName	EmployeeName
> ========================
> Acme Corp	Bloggs, Jones, Smith
> Microshag	Gates, Williams
>
> Can you see what I'm getting at?  We are trying to use hierarchical
> recordsets, and are finding they are quite slow....
>
> James H




____________________________________
Automated Home UK
http://www.automatedhome.co.uk
____________________________________

Your use of Yahoo! Groups is subject t  http://docs.yahoo.com/info/terms/




Home | Main Index | Thread Index

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.