You'll have to change your tb_booking_email dataset to have only the rows with max id and then join. Something like,select * from tb_booking_check join ( select a.col1, a.col2, a.col3..,a.booking_emails_booking_id from tb_booking_email a where booking_emails_booking_id= ( select max(booking_emails_booking_id) from tb_booking_email where col1=a.col1 and col2=a.col2 and col3=a.col3 .... ) )tb_booking_email on tb_booking_check.bc_booking_id=tb_booking_email.booking_emails_booking_id ...
Makes sense ?