我正在尝试创建一个视图来显示我在表格中的信息。我遇到的麻烦是连接两个表,然后分别显示数据。
我有两张桌子:一张是tbl_videos
,另一张是tbl_categories_videos
。tbl_videos
有两个类别字段,都取自tbl_categories_videos
. category_id
s 正确显示,但是tbl_videos
当我创建视图时,我无法正确显示类别名称。
我能做到的最接近它的工作是两者在视图category_1
中category_2
显示相同的值,但应该不同。
我盯着屏幕看太久了,所以我可能错过了一些简单的东西。
无论如何,这是我的视图 SQL:
CREATE VIEW `VIDEOS_view` AS
SELECT `tbl_videos`.`videos_id` AS `videos_id`,
`tbl_videos`.`date` AS `date`,
`tbl_videos`.`author` AS `author`,
`tbl_videos`.`photo_credit` AS `photo_credit`,
`tbl_categories_videos`.`category_videos_name` AS `category_1`,
`tbl_categories_videos`.`category_videos_name` AS `category_2`,
`tbl_videos`.`thumb` AS `thumb`,
`tbl_videos`.`image_1` AS `image_1`,
`tbl_videos`.`video_embed` AS `video_embed`,
`tbl_videos`.`title` AS `title`,
`tbl_videos`.`sub_title` AS `sub_title`,
`tbl_videos`.`section_1` AS `section_1`,
`tbl_videos`.`section_2` AS `section_2`,
`tbl_videos`.`embed` AS `embed`
FROM ((`tbl_videos` join `tbl_categories_videos` on (
(`tbl_videos`.`category_id_1` AND
`tbl_videos`.`category_id_2` =`tbl_categories_videos`.`category_videos_id`
))))
任何帮助将非常感激。