Re: SQL Query Assistance

Dale E. Reed Jr. ( (no email) )
Sat, 28 Feb 1998 23:08:55 -0800

Michael Whisenant wrote:
>
> I have tried... this does not work...
>
> SELECT SubAccounts.Login, SubAccounts.PhoneHome, SubAccounts.PhoneWork,
> SubAccounts.FirstName, SubAccounts.LastName, MasterAccounts.Region
> FROM SubAccounts, MasterAccounts
> Where login > ""
> GROUP BY SubAccounts.Login, SubAccounts.PhoneHome, SubAccounts.PhoneWork,
> SubAccounts.FirstName, SubAccounts.LastName, MasterAccounts.Region
> ORDER BY SubAccounts.Login
> GO

As noted earlier, when you include more than one table, you need to
join them via some field. Otherwise SQL Server gives all combinations,
which is what can take so long.

SELECT sa.Login, sa.PhoneHome, sa.PhoneWork, sa.FirstName, sa.LastName,
ma.Region
FROM SubAccounts sa, MasterAccounts ma
Where sa.CustomerID = ma.CustomerID
AND sa.login <> ' '
ORDER BY sa.Login


You don't need the group stuff

-- Dale E. Reed Jr.  (daler@iea-software.com)_________________________________________________________________       IEA Software, Inc.      |  RadiusNT, Emerald, and NT FAQs Internet Solutions for Today  |   http://www.iea-software.com