Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Unanswered: Help in using joins

    hi..
    am using three tables personaldetails,tribedetails,wifedetails..
    personaldetails with primarykey , now i want to show details of one user from three tables by using joins. Here in first table(personaldetails) am taking wife column for database purpose if the user wife exists then am taking wife column as "1" if she is not exists value is "0" in personaldetails table ,, so now i want a query showing one user details from all the tables by taking primartkey from first table and foreighnkey from other two tables...only condition is if user exists wife we have to show her details and if she not nothing to display about her and only first two tables we have to show...

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Wonder what kind of "wife details" are you showing?
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Aug 2010
    Posts
    2

    joins

    am showing all wife details in wifedetails table..

  4. #4
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    So your user population is fully comprised of males? Is it because women are not allowed to use a computer?
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Perhaps he is writing a membership database for The Hair Club For Men.

    Praveen, I'm having difficulty finding a specific question in your post, but I suspect what you need is a "LEFT OUTER JOIN" to the wife table, to display wife data if it exists, but to avoid filtering persondetails records if no wife exists.

    Also, your use of a boolean flag to indicate whether a wife exists is unnecessary, since this can be logically determined by whether a wife record exists.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  6. #6
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Maybe the bit column is intended to show which wife is current? Oh, wait. Wrong table...

  7. #7
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    ...and maybe if it's a female...
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  8. #8
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    or an exists/not exists subselect

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •