Solved

inner join of 4 table

Posted on 2011-09-20
1
342 Views
Last Modified: 2012-05-12
I am trying to do innner join of 4 table and in my table there is only 2 record but I am doing something wrong in neer join it's repeating and getting total 4 record with saem repeating value.
please help me out with this.



      select  
       customer.Member_Status
      select customer.First_Name
      from      Link_Payment,Customer,Payment_Info,PersonalInfo,Customer_Subscription
       where customer.primarykey = PaymentInfo.UserID and
       customer.primarykey= PersonalInfo.UserID      and
      Link_Payment.SubscriptionID= Customer_Subscription.primaryKey and
        First_Name like 'john%'
0
Comment
Question by:Itgirl16
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 500 total points
ID: 36571051
there is connection between Link_Payment and Customer_Subscription to rest of the tables
select customer.Member_Status, customer.First_Name 
from Customer      
inner join PersonalInfo on customer.primarykey = PersonalInfo.UserID
inner join PaymentInfo on customer.primarykey = PaymentInfo.UserID

--you have not defined these relationaships
inner join Link_Payment on customer.primarykey = Link_Payment.PrimaryKey
inner join Customer_Subscription on Link_Payment.SubscriptionID= Customer_Subscription.primaryKey 
--

where First_Name like 'john%'

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

690 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