Receiving an syntax error

  • Do you know that i am still racking my brain on this one.

    MAN if you could help me on this so i can move forward.

    I have posted a picture that you may see the tables that i am pulling from.

    This is beyond me at this point.

    I am including a photo on a url so that you may have a look at the web site.

    http://afcc1.com/sqlHELP

    What i am tring to do here is get the is very simple for someone who knows a little more about this than i do.

    ==============================================

    I NEED the ProductID , ProductCategoryName , and the CompanyID

    WHERE the companyid = @idcompany

    and Categories.Productcategoryid = 20 (0r something like this)

    =============================================

    With you looking at the web url can you see what i need to do?

    Thank you!

    Erik

    Dam again!

  • Not too sure (think I don't see all the tables/relation in this).

    How about this ? :

    Create a new view using enterprise manager.

    Select all the tables you need (to display the data and have all the joins). Then select the fields you want to see and add the where condition(s). If you're like me you need to see what's going on to grasp the concept at first.

    Talk to you tomorrow.

  • ok thanks!

    Dam again!

  • Hmm... not sure what you need, but maybe it is this?

    SELECT p.ProductID, c.ProductCategoryName, p.CompanyID

    FROM Product p

    JOIN Categories c on c.ProductCategoryId = p.ProductCategoryId

    WHERE p.companyid = @idcompany

    AND c.Productcategoryid = 20

    HTH, Vladan

  • That's almost what I had but I wasn't sure of the relations....

  • Are you guessing again ???


    * Noel

  • No, just wondering if that would have worked and what would have been showed (too lazy to recreate the situation ).

    [EDITED]

    oops wrong thread.

  • I have been on this all day yesterday and i am on it again.

    I am not sure what is going on with such a simple query. At this point i am monitoring everything that i am doing because i want to be able to idenify the problem when this happens again. It has to be the way i have my relationships set up. However, there is only three tables involved and i am using the product table as a middle man. What can i be doing wrong that is causing it to produce this wierd result? I NEED to move forward and i am stuck in a small whole that my level of sql2000 knowledge will not let me be untill i obey!

     

    Looking for help here!

     

    Dam again!

  • HERE is where i am

    ALTER PROCEDURE GetBlindMenuInfoCTaLL

    @IDCompany int

    AS

    SELECT c.CompanyName, c.CompanyID, ca.ProductCategoryName, p.ProductID

    FROM Company C

       JOIN Product P ON C.CompanyId = P.CompanyId

       JOIN Categories CA ON CA.ProductCategoryId = P.ProductCategoryID

    WHERE C.CompanyID = 16

    AND ca.CategoryTypeID = 20

    ORDER BY C.CompanyName

    Dam again!

  • Can you paste the script to recreate the tables/index/relations and insert some sample data. I'll build it for you on my pc yif you can send me this.

  • What's wrong with that?

  • It is producing doubles and tripples of that products in the product table and not grabbing the ProductCategoryName for the Categories table.

    Dam again!

  • I can't help you if you don't post the data and table definition.

  • in other words it is producing doubles of the PROUCT name from the product table and not getting the ProductCategoryName from the Categories table~~~

    Dam again!

  • I am not posted data on  a forum before, is there a place for me to do that?

    Dam again!

Viewing 15 posts - 16 through 30 (of 66 total)

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