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: www.automatedhome.co.uk gone?


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

Re: Re: [OT] SQL question


  • To: ukha_d@xxxxxxx
  • Subject: Re: Re: [OT] SQL question
  • From: "Steve Cooper" <steve.cooper@xxxxxxx>
  • Date: Wed, 11 Jul 2001 12:26:20 +0100
  • 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


If you are using things like MIN or FIRST make sure you use an ORDER BY
statement.  SQL does not guarantee the order that data is returned in if
you don't use one.

Example:  At work we have a SQL 7 database table that has a clustered index
on it and a Select * from TABLE1 returns the data in a different order
depending on whether the database is read-only or not.

Steve



"Mark Pollock"
<pollocmc@total        To:     ukha_d@xxxxxxx
ise.co.uk>             cc:
Subject:     [ukha_d] Re: [OT] SQL question
11/07/01 11:33
Please respond
to ukha_d






I actually get to answer something on this group, Hooray!

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];

Mark

--- In ukha_d@y..., "James Hoye" <james.hoye@s...> wrote:
> Sorry for asking something completely non-HA, but I know you're such
a
> knowledgeable bunch...
>
> I have 2 tables, A and B where A has a one-many relationship with B
>
> How can I select from table A and only return the FIRST joined
record from
> B.
>
> Table A:
> ID CompanyName
> =================
> 1  Acme Corp
> 2  Microshag
>
> Table B:
> CompanyID    EmployeeName
> ========================
> 1       Bloggs
> 1       Jones
> 1       Smith
> 2       Gates
> 2       Williams
>
> I need the SQL statement (if one exists) that will produce:
>
> CompanyName  EmployeeName
> ========================
> Acme Corp    Bloggs
> Microshag    Gates
>
> I'll be using Access2000/JET4
>
> Sorry for all those non-SQL bods...
>
> James H




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

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








____________________________________
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.