Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for a Look-up method 1

Status
Not open for further replies.

kupe

Technical User
Sep 23, 2002
376
Table Correspondence contains the letters. Table Correspondents contains the names of those who have written the correspondence.

How can I use the Correspondents – the letter-writers – as a look-up table, please?

Then '1' in the Correspondence table would be 'Joe Bloggs' in the letter-writers table, and '2' in the Correspondence table would be 'Anthony Blair' in
the letter-writers table, please Gurus?
 
How about something like:
[tt]
SELECT l.*,w.name
FROM
correspondence l
LEFT JOIN correspondents w ON l.writer=w.id
[/tt]
where the Correspondence table's "writer" field contains the writer's id number, and the Correspondents table contains the field "id" and "name".
 
Many thanks, Tony, only the clock is whizzing past and I am not grasping this. Sorry.

Actually, I have a table 'Post' and one 'LWriters'. LWriters has the name of each letterwriter with an id.

Post has just the letterwriterid to tell us which is from whom.

I want to be able to join the two in a query. But, it doesn't want to go. Any hints (polite ones) please?
 
Unless I'm missing something, you would just have to change the table and field names:
[tt]
SELECT p.*,w.name
FROM
post p
LEFT JOIN lwriters w ON p.letterwriterid=w.id
[/tt]
 
Oops, I think I might have been.

Much obliged.

(I have all your replies in a notebook. I wonder if your ears burn at all hours of the day and the night. Your name is - almost - perpetually associated with my mysql. Really very grateful for your help.)
 
No trouble. Researching solutions to other people's problems is educational for me as well; I keep discovering new ways to improve my own systems.
 
Long may it be so! All the best.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top