Reputation: 11
I have 2 tables
Table 1: dit_news
1. id
2. title
3. body
4. date
5. posterID
Table 2: dit_users
1. id
2. fullName
3+ a bunch of irrelevant to this problem columns
dit_news.posterID
equals that of dit_users.id
I need a way of getting the fullName
record where the dit_users's ID equals that of posterID
in dit_news
. I hope that makes sense. Any help would be greatly appreciated.
Upvotes: 1
Views: 100
Reputation: 1984
SELECT
dit_users.fullName
FROM
dit_news
JOIN dit_users ON
dit_news.posterID = dit_users.id
;
You may want to add WHERE dit_news.id = N
to retrieve the name of the user for article N only.
Upvotes: 0
Reputation: 204756
select distinct u.fullName
from dit_users u
inner join dit_news n on n.posterID = u.id
Upvotes: 0
Reputation: 116098
SELECT u.fullname
FROM dit_users u
JOIN dit_news n ON (n.posterid = u.id)
WHERE n.id = 12345
Upvotes: 0
Reputation: 20063
SELECT dit_users.fullName FROM ditusers INNER JOIN dit_news ON dit_users.id = dit_news.posterID
Upvotes: 2