我试图在我的max()
中使用sql
,但我很困惑,因为我正在使用join
表,我不知道我应该在哪里插入max()
我需要在表date_issue
crew_documents_table
这是我的sql:
select *
from
info join
crew_documents_table on info.id = crew_documents_table.document_crew_id join
crew_rank on info.crew_rank = crew_rank.crew_rank_id
where
crew_rank in ('1','2','3','4','5') and
crew_status = '$crew_status' and
vessel = '$vessel_name'
group by full_name
答案 0 :(得分:1)
您可以自定义SQL查询,如下所示:
select *, MAX(crew_documents_table.date_issue) as max_date
from
info join
crew_documents_table on info.id = crew_documents_table.document_crew_id join
crew_rank on info.crew_rank = crew_rank.crew_rank_id
where
crew_rank in ('1','2','3','4','5') and
crew_status = '$crew_status' and
vessel = '$vessel_name'
group by full_name
MAX可让您选择最长日期