﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / inner join returns cartesian product why? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 05:36:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: inner join returns cartesian product why?</title><link>http://www.sqlservercentral.com/Forums/Topic1074608-338-1.aspx</link><description>[quote][b]Michael Tocik (3/8/2011)[/b][hr]dope!:blush:My mistake....I was joining on the wrong field[/quote]Easily done. Try to get into the habit of using table aliases:SELECT i.order_number FROM INVOICE_DETAIL_CONF_ALL iINNER JOIN ORDER_EXTRACT_AUTO o	ON o.[Ord No] = i.ORDER_NUMBER</description><pubDate>Tue, 08 Mar 2011 04:59:51 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: inner join returns cartesian product why?</title><link>http://www.sqlservercentral.com/Forums/Topic1074608-338-1.aspx</link><description>dope!:blush:My mistake....I was joining on the wrong field</description><pubDate>Tue, 08 Mar 2011 04:47:46 GMT</pubDate><dc:creator>Michael Tocik</dc:creator></item><item><title>RE: inner join returns cartesian product why?</title><link>http://www.sqlservercentral.com/Forums/Topic1074608-338-1.aspx</link><description>[quote][b]Michael Tocik (3/7/2011)[/b][hr]Hi,I have two order tables that I am trying to join. Both have have 13 records in them but when I do an inner join on the order number I get 169 records. Both tables have a data type of varchar(7) Here is the join;SELECT INVOICE_DETAIL_CONF_ALL.order_number FROM INVOICE_DETAIL_CONF_ALL	inner join ORDER_EXTRACT_AUTO	on [Ord No]  = ORDER_NUMBERWhat am I missing?[/quote]Apart from some DDL code to see what the tables look like?So just guessing wild:- All the rows in both tables actually have the same Order_number- You joining on 2 columns from the same table. Try and add the table name before the column./T</description><pubDate>Mon, 07 Mar 2011 23:54:16 GMT</pubDate><dc:creator>tommyh</dc:creator></item><item><title>inner join returns cartesian product why?</title><link>http://www.sqlservercentral.com/Forums/Topic1074608-338-1.aspx</link><description>Hi,I have two order tables that I am trying to join. Both have have 13 records in them but when I do an inner join on the order number I get 169 records. Both tables have a data type of varchar(7) Here is the join;SELECT INVOICE_DETAIL_CONF_ALL.order_number FROM INVOICE_DETAIL_CONF_ALL	inner join ORDER_EXTRACT_AUTO	on [Ord No]  = ORDER_NUMBERWhat am I missing?</description><pubDate>Mon, 07 Mar 2011 23:22:58 GMT</pubDate><dc:creator>Michael Tocik</dc:creator></item></channel></rss>