Reputation: 31
im trying to use max()
here in my sql
but im confused because i am using join
table and i dont have idea where i should insert the max()
i need to add the column name date_issue
from the table crew_documents_table
here is my 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
Upvotes: 1
Views: 48
Reputation: 2525
You can customize your SQL query as below :
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 allows you to select the maximum date
Upvotes: 1