How do I get "Merge Join/Inner Join" working?

  • Hello Gurus!

    Have a look at this query in Query Analyzer (provided you have the Northwind DB installed):

    
    
    SELECT CustomerID, OrderID, OrderDate
    FROM Northwind.dbo.Orders
    WHERE CustomerID = 'GREAL'
    AND OrderDate = '04/30/98'

    It does a "Merge Join/Inner Join" on two (non-clustered) indexes. Now, I tried the same with a table of my own. Both the colums I use are indexed but I don't get the same output! Instead I get a Bookmark Lookup and a Filter. What am I doing wrong?

    Could it be that I don't have enough rows in my table?

    And another question... If I have two indexes on two different tables can a "Merge Join" be used there too? I can't find an example of that anywhere. It would reduce I/O considering that no Bookmark Lookup would be required. Almost like a covering index, right?

    Thanks!

    /Tomi

  • I get this somtimes because of the date feild. Sometimes I have to put in the exact format without the single apostophe, like 2003-05-28 00.00.000 . It may depend on how the field types are set up in the table designer.

    to go between tables and get different columns from those tables, try using the full table path, like:

    SELECT Southtown.CustomerID, Orders.OrderID, Orders.OrderDate

    FROM Northwind.dbo.Southtown, Northwind.dbo.Orders

    WHERE Orders.CustomerID = 'GREAL'

    AND Orders.OrderDate = '04/30/98'

    In this example there is a Southtown table, and the Orders table. I made up the southtown part, just to show example. I use SQL 7.0.

  • Thanks for the reply!

    Yes, it seems to have something to do with the date field. Kinda weird...

    I think I'll run the Index Tuning Wizard after I've added some samle data. Maybe it will give me some good advice.

    Thanks again

    /Tomi

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply