Results 1 to 7 of 7

Thread: LEFT JOIN issue

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    592

    Question LEFT JOIN issue

    Code:
    SELECT 
    		Ord.orderID, Ord.DateCreated, Ord.DateShipped, 
    		Ord.OrderTotal, Ord.Subtotal, Ref.UrlReferrer AS Referrer
    	FROM 
    		customer_Orders AS Ord
    	INNER JOIN
    		customer_WebStatistics AS Ref
    	ON
    		Ord.IPAddress = Ref.IPAddress
    	WHERE
    		(Ord.DateShipped >= @StartDate AND Ord.DateShipped <= @EndDate)
    	AND 
    		Ord.IPAddress 
    	IN 
    		(
    			SELECT 
    				IPAddress 
    			FROM 
    				customer_WebStatistics 
    			WHERE 
    				UrlReferrer <> @CurrentDomain 
    			AND 
    				Ref.EnterDate = Ord.DateCreated
    		)

    I am aware that this will not work as expected. However i wanted to give you an idea of what i am trying to achive here.


    Basically i want to returns all orders no matter if there is Referrer or NO.

    The referrer should be included ONLY if it happened on the same date with the order AND if UrlReferrer contains the Request.ServerVariables("SERVER_NAME").

    Thanks for any ideas
    Last edited by selanec; Jun 25th, 2010 at 10:55 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width