Query Problem

  • Hi there I have a query that should bring back info from four tables to show all ticket sales for west end shows. Here is the query

    SELECT tblCustomer.CustomerID, tblCustomer.Title, tblCustomer.[First Name], tblCustomer.[Last Name], tblOrders.[Order Number], tblOrders.[Number of Tickets], tblActualShows.[Performance Date], tblActualShows.ShowNameID, tblShowNames.[Show Description]

    FROM tblShowNames INNER JOIN (tblCustomer INNER JOIN (tblActualShows INNER JOIN tblOrders ON tblActualShows.ShowID = tblOrders.ShowID) ON tblCustomer.CustomerID = tblOrders.CustomerID) ON tblShowNames.ShowNameID = tblActualShows.ShowNameID

    WHERE (((tblOrders.[Order Number])=95415));

    I have a complete table pre normalisation that stores all the data. When I query this table for order number 95415 the show name is Blood Brothers, but in the complete query above it brings back a show called We Will Rock YOU. If I remove the order number from the query above to bring back all rows - it shows WE WILL ROCK YOU FOR ALL ROWS.

    Any help please.....

  • Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I assume that whatever process you have that is converting your "pre-normalized" table into these four tables is flawed. So you may want to include the information about that as well.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

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

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