2つのMySQLビューが機能しています。
portfolio
最初のビューは、IDがテーブルにあるすべての行をテーブルから選択しますmural
。
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `view_mural` AS
select
`portfolio`.`id` AS `id`,
`portfolio`.`customer_id` AS `customer_id`,
`portfolio`.`location_id` AS `location_id`,
`portfolio`.`title_text_id` AS `title_text_id`,
`portfolio`.`description_text_id` AS `description_text_id`,
`portfolio`.`started` AS `started`,
`portfolio`.`finished` AS `finished`,
from
`portfolio`
where
`portfolio`.`id` in (select
`mural`.`portfolio_id`
from
`mural`) WITH CASCADED CHECK OPTION
2番目のビューは、2つのテーブルから行を選択します:portfolio
およびmural
。
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `view_mural` AS
select
`portfolio`.`id` AS `id`,
`portfolio`.`customer_id` AS `customer_id`,
`portfolio`.`location_id` AS `location_id`,
`portfolio`.`title_text_id` AS `title_text_id`,
`portfolio`.`description_text_id` AS `description_text_id`,
`portfolio`.`started` AS `started`,
`portfolio`.`finished` AS `finished`,
(select
`mural`.`width`
from
`mural`
where
`mural`.`portfolio_id`=`portfolio`.`id`) AS `mup`
from
`portfolio`
これらを1つのビューに結合して、両方のテーブルの列を含むテーブルを選択する方法を取得できません。このテーブルには、テーブル壁画にもIDが含まれるテーブルポートフォリオの行が含まれています。
追加すると:
where
`portfolio`.`id` in (select
`mural`.`portfolio_id`
from
`mural`) WITH CASCADED CHECK OPTION
2番目のビューの最後まで、エラーが表示されます。
Apply changes to view_mural Error 1368: CHECK OPTION on non-updatable view 'view_mural' SQL Statement: CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = `root`@`localhost` SQL SECURITY DEFINER VIEW `view_mural` AS select `portfolio`.`id` AS `id`, `portfolio`.`customer_id` AS `customer_id`, `portfolio`.`location_id` AS `location_id`, `portfolio`.`title_text_id` AS `title_text_id`, `portfolio`.`description_text_id` AS `description_text_id`, `portfolio`.`started` AS `started`, `portfolio`.`finished` AS `finished`, (select `mural`.`width` from `mural` where `mural`.`portfolio_id`=`portfolio`.`id`) AS `mup` from `portfolio` where `portfolio`.`id` in (select `mural`.`portfolio_id` from `mural`) WITH CASCADED CHECK OPTION Error when running failback script. Details follow. Error 1050: Table 'view_mural' already exists SQL Statement: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_mural` AS select `portfolio`.`id` AS `id`,`portfolio`.`customer_id` AS `customer_id`,`portfolio`.`location_id` AS `location_id`,`portfolio`.`title_text_id` AS `title_text_id`,`portfolio`.`description_text_id` AS `description_text_id`,`portfolio`.`started` AS `started`,`portfolio`.`finished` AS `finished`,(select `mural`.`width` from `mural` where ((`mural`.`portfolio_id` = `portfolio`.`id`) and `portfolio`.`id` in (select `mural`.`portfolio_id` from `mural`))) AS `mup` from `portfolio`
誰かが私にそれをどのように行うことができるかを教えてもらえますか?