select c.id,c.cargoinfo_id,c.cargociq_id,
(select ciqcode from Import_cargociq where id=c.cargociq_id) cargociq,
a.cargoinfo_id,a.cargociq_id,
(select ciqcode from Import_cargociq where id=a.cargociq_id) appciq
 from import_cargo c
left join Import_appstate s on s.cargo_id=c.id
left join Import_approval a on a.id=s.app_id
left join import_main m on m.contractno=c.contractno
where c.cargociq_id<>a.cargociq_id