-1

我有两个表:第一个表(出发)包含以下列:

1 - departid
2 - departname

第二个表(消息)包含以下列:

1 - messageID
3 - SentFromDepartID
4 - SentToDepartID
5 - ReplyMessage
6 - mdate

我想查询消息并获取启程名称而不是启程编号。你能帮助我吗?

4

1 回答 1

2
select m.*, 
       dfrom.departname as fromname,
       dfrom.departname as toname
from messages m
join departs dfrom on dfrom.departid = m.sentfromdepartid
join departs dto on dto.departid = m.senttodepartid
于 2013-11-09T23:25:59.327 回答