locked
Inner join and Where ID = @ID RRS feed

  • Question

  • User-1601837296 posted

    Hi.

    I am using 3 tables and are trying to get the correct info belonging to the correct id. Like this: I go to a page and here i want to see the information from the 3 tables using a specific id.

    I have written this so far in a query:

    SELECT Profiles.ProfileID, Profiles.FirstName, Profiles.LastName, ProfileInfos.Height, ProfileInfos.Weight, ProfilePictures.PictureURL FROM Profiles
    INNER JOIN ProfileInfos ON Profiles.ProfileID = ProfileInfos.ProfileID
    INNER JOIN ProfilePictures ON Profiles.ProfileID = ProfilePictures.ProfileID
    WHERE ProfileID = @ProfileID

    My problem is that the last line does not work and i am uncertain how to make this work? How to write it correctly that is.

    Sunday, March 6, 2011 9:10 AM

Answers

  • User-2139489267 posted

    Your query seems ok to me, aren't you passing id? Are you getting any error?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 6, 2011 9:53 AM
  • User-1601837296 posted

    Yes, when i try to save it says "Ambiguous column name 'ProfileID'"

    If i run the QueryBuilder there is no problem.

    EDIT: Fascinating. After adding the last line like this: (Profiles.ProfileID = @ProfileID) it suddenly works. Thanks for taking your time to read and trying to help with my (past) problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 6, 2011 10:32 AM

All replies

  • User-2139489267 posted

    Your query seems ok to me, aren't you passing id? Are you getting any error?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 6, 2011 9:53 AM
  • User-1601837296 posted

    Yes, when i try to save it says "Ambiguous column name 'ProfileID'"

    If i run the QueryBuilder there is no problem.

    EDIT: Fascinating. After adding the last line like this: (Profiles.ProfileID = @ProfileID) it suddenly works. Thanks for taking your time to read and trying to help with my (past) problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 6, 2011 10:32 AM