Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / July 2008

Tip: Looking for answers? Try searching our database.

Can I use LEFT JOIN to solve this problem ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 27 Jun 2008 10:21 GMT
There are 2 tables in an application system.

The first table "grpmem" contains both group_id and member fields.

In the second table "ctct", it contains both data for Role and Member (First
Name and Last Name).

I have created 2 queries so that the first one retrieve the Group Name while
the second one retrieve the Member Name.   Then I export it to an Access
Database and perform a LEFT JOIN (There are more Groups than Members).

I just wonder whether it can be achieved by running a SQL Script.

Thanks
TheSQLGuru - 27 Jun 2008 15:06 GMT
Sure would be helpful to have table scripts and some sample data with
expected output.

Signature

Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net

> There are 2 tables in an application system.
>
[quoted text clipped - 11 lines]
>
> Thanks
Patrick - 28 Jun 2008 09:54 GMT
Thank you for your reply.  I will give you more information when I am back
to work next week.

Thanks again.

> Sure would be helpful to have table scripts and some sample data with
> expected output.
[quoted text clipped - 14 lines]
>>
>> Thanks
Patrick - 30 Jun 2008 10:09 GMT
Dear Kevin,

Please find some sample data.

select id, c_last_name from ctct where id = 735169
id                    c_last_name
735169            Property Service Officer

select id, c_first_name, c_last_name from ctct where id = 437418
id                     c_first_name      c_last_name
437418            James                 Pang

The result I would like to get is as follow (This is because the Role
returned is more than the rows of Name)
780205            Property Service Officer      James       Pang
780256            Property Service Supervisor
780257            Property Service Manager      Gary        Poon

> Sure would be helpful to have table scripts and some sample data with
> expected output.
[quoted text clipped - 14 lines]
>>
>> Thanks
TheSQLGuru - 01 Jul 2008 14:38 GMT
That isn't nearly sufficient to help here.  The 2 rows you returned dont'
even represent data you expect, Role isn't defined, etc.  Entire table
script and sufficient sample data to know what should be included and what
should NOT be included would be required.

Signature

Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net

> Dear Kevin,
>
[quoted text clipped - 32 lines]
>>>
>>> Thanks
Patrick - 01 Jul 2008 23:13 GMT
Dear Kevin,

I have missed one query.

The queries should be
select * from grpmem where id = 780205
id          Group Id    member
780205            735169            437418

select id, c_last_name from AHD.ctct where id = 735169
id          c_last_name
735169            Property Service Officer

select id, c_first_name, c_last_name from ctct where id = 437418
id          c_first_name      c_last_name
437418            James       Pang

> That isn't nearly sufficient to help here.  The 2 rows you returned dont'
> even represent data you expect, Role isn't defined, etc.  Entire table
[quoted text clipped - 37 lines]
>>>>
>>>> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.