Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drop view `v_ra_status`;
- create VIEW `v_ra_status` AS
- SELECT
- `ct`.`insured_locationID` AS `insured_locationID`,
- `ct`.`change_reason` AS `change_reason`,
- `msc`.`status_policy_newID` AS `status_policyID`,
- `msc`.`status_policy_change_reasonID` AS `status_policy_change_reasonID`,
- `msc`.`m_status_changeID` AS `m_status_changeID`,
- `sp_new`.`nameNL` AS `ra_statusNL`,
- `sp_new`.`nameEN` AS `ra_statusEN`,
- `spcr`.`code_change_reason` AS `code_change_reason`,
- `spcr`.`nameNL` AS `nameNL`,
- `spcr`.`nameEN` AS `nameEN`,
- `ct`.`updated` AS `updated`,
- `ct`.`due_date` AS `due_date`,
- `ct`.`agenda` AS `agenda`,
- `ct`.`agenda_tp` AS `agenda_tp`,
- `ct`.`remark` AS `remark`,
- `ct`.`done` AS `done`,
- `ct`.`remark_tp` AS `remark_tp`,
- `ct`.`done_tp` AS `done_tp`,
- `ct`.`_z_rel_insured_location__m_status_changeID` AS `_z_rel_insured_location__m_status_changeID`
- FROM _z_rel_insured_location__m_status_change ct
- inner join m_status_change msc on msc.m_status_changeID = ct.m_status_changeID
- inner join status_policy sp_new on sp_new.status_policyID = msc.status_policy_newID
- inner join status_policy_change_reason spcr on spcr.code_change_reason = msc.status_policy_change_reasonID
- order by ct.insured_locationID, ct.updated desc limit 1;
- If I test it like this:
- SELECT
- `ct`.`insured_locationID` AS `insured_locationID`,
- `ct`.`change_reason` AS `change_reason`,
- `msc`.`status_policy_newID` AS `status_policyID`,
- `msc`.`status_policy_change_reasonID` AS `status_policy_change_reasonID`,
- `msc`.`m_status_changeID` AS `m_status_changeID`,
- `sp_new`.`nameNL` AS `ra_statusNL`,
- `sp_new`.`nameEN` AS `ra_statusEN`,
- `spcr`.`code_change_reason` AS `code_change_reason`,
- `spcr`.`nameNL` AS `nameNL`,
- `spcr`.`nameEN` AS `nameEN`,
- `ct`.`updated` AS `updated`,
- `ct`.`due_date` AS `due_date`,
- `ct`.`agenda` AS `agenda`,
- `ct`.`agenda_tp` AS `agenda_tp`,
- `ct`.`remark` AS `remark`,
- `ct`.`done` AS `done`,
- `ct`.`remark_tp` AS `remark_tp`,
- `ct`.`done_tp` AS `done_tp`,
- `ct`.`_z_rel_insured_location__m_status_changeID` AS `_z_rel_insured_location__m_status_changeID`
- FROM _z_rel_insured_location__m_status_change ct
- inner join m_status_change msc on msc.m_status_changeID = ct.m_status_changeID
- inner join status_policy sp_new on sp_new.status_policyID = msc.status_policy_newID
- inner join status_policy_change_reason spcr on spcr.code_change_reason = msc.status_policy_change_reasonID
- where ct.insured_locationID = 133918
- order by ct.insured_locationID, ct.updated desc limit 1
- I have one row as expected
- When I try to use the view like this:
- select
- `ra`.`insured_locationID`,
- `vrs`.`status_policyID`
- from
- `insured_location_c` `ra`
- inner join
- `v_ra_status` `vrs` ON `vrs`.`insured_locationID` = `ra`.`insured_locationID`
- where ra.insured_locationID = 133918
- I have 0 rows and expected 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement