I am new to inner joins and i have a query that has had me stumped for a few days, I basically have a query in which I am trying to pull out records from rows that match on different tables this is what I have..
var sql = "SELECT t.*,
p.*
FROM Threadposts t
INNER JOIN profiles p
ON t.profileID = p.ProfileID
WHERE t.threadID = @id";
I am getting the results from Threadposts t but profile p is always null. What the query is supposed to say is this
Get all of the results from table Threadposts and profiles where Threadpost.threadID= @id and also get the profile rows where t.profileID = p.ProfileID
The @id is a forum page so essentially if your on forum page 20 then I want to get all the users that have posted on forum page 20 hence the Threadpost.thread= @id . After we get the user replies then lets get they're profile information to also display they're names etc. above they're post hence t.profileID = p.ProfileID . As stated above I get all of they're replies so Threadpost works but something is going on with the Profiles, what are things I can do to fix that?
Threadpost has fields: profileID and ThreadID profileID is the unique identification that each user has and ThreadID is the page number that corresponds to a forum posted in. When someone clicks on Forum page 20 then the id=20 which is then matched with ThreadID of 20 and each of those rows will have a ProfileID of users; I want to use that ProfileID and match it with the profileID in the profiles table so i can get the users name and location.