Results 1 to 3 of 3

Thread: Too many rows after Join in SQL

  1. #1
    Join Date
    Feb 2009
    Posts
    38

    Too many rows after Join in SQL

    When I perform join operation on two tables, I get too many rows than actually it should appear.
    How do I fix it ?
    If anyone knows any solution or alternative to this.... then please suggest.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Too many rows after Join in SQL

    When you join tables, make sure that the number of join predicates in the search condition is one less than the number of tables in the from list. Otherwise, you will get many more rows returned than you probably intended.

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Too many rows after Join in SQL

    The problem you are facing(extra rows) is called a Cartesian product.
    You basically asked for a combination of every value from one table matched to every value from the other table. In your case you did have an "except"-type condition so you eliminated a few of the matches.

    Let me explain it this way:
    Imagine you have two identical lists of names.
    Each list is 200 names long and there are no duplicates within the list.
    The query you just wrote would combine each of the first 200 names with
    each one of the other 199 names from the other table that didn't match so
    that your final results would be (200x199) or 39800 records, way more than
    the 400 you started with.....

Similar Threads

  1. Replies: 3
    Last Post: 02-06-2012, 12:44 PM
  2. Replace Duplicate Rows
    By ajk79 in forum Windows Software
    Replies: 1
    Last Post: 20-07-2010, 11:01 AM
  3. How to Insert Multiple Rows At Once in PHP
    By Zeverto in forum Software Development
    Replies: 3
    Last Post: 22-09-2009, 03:30 PM
  4. Replies: 2
    Last Post: 09-07-2009, 08:57 AM
  5. Equi Join vs Natural Join in SQL
    By Demetrius in forum Software Development
    Replies: 3
    Last Post: 14-05-2009, 12:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,030,378.28660 seconds with 16 queries