mysql - how can i retrieve the child table data from master table in a string value -
this master table structure
create table if not exists `gf_film` ( `film_id` bigint(20) not null auto_increment, `user_id` int(20) not null, `film_name` varchar(100) default null, `film_cat` varchar(30) character set latin1 default null, `film_plot` longtext, `film_release_date` date default null, `film_post_date` date default null, `film_type` enum('movie','tv') character set latin1 default 'movie', `film_feature` enum('y','n') character set latin1 not null default 'n', `film_status` enum('active','inactive') character set latin1 not null default 'active', `film_modify` timestamp not null default current_timestamp on update current_timestamp, `film_link_value` varchar(200) not null, `film_post_link` varchar(255) not null, primary key (`film_id`) ) engine=myisam default charset=utf8 auto_increment=21435 ;
this child table through map between above gf_film table , lowest gf_actor table
create table if not exists `gf_film_actor` ( `film_id` int(20) not null, `actor_id` int(20) not null, key `film_id` (`film_id`) ) engine=myisam default charset=latin1;
this table have reitrieve actor name
create table if not exists `gf_actor` ( `actor_id` bigint(20) not null auto_increment, `actor_name` varchar(100) default null, `actor_desc` longtext character set latin1, primary key (`actor_id`), unique key `actor_name` (`actor_name`) ) engine=myisam default charset=utf8 auto_increment=60963 ;
and schema gf_film_poster
create table if not exists `gf_film_poster` ( `film_id` int(20) not null, `website_poster_url` varchar(255) default null, `original_poster_url` varchar(255) default null, `default_poster_url` varchar(255) default 'noposter.gif', unique key `film_id` (`film_id`) ) engine=myisam default charset=latin1;
after execute query
select gf_film.film_id , film_name , date_format(film_release_date,'%d') date , date_format(film_release_date,'%m') month_ori, date_format(film_release_date,'%m') month , date_format(film_release_date,'%y') year , film_release_date , film_feature , film_modify , film_post_link , website_poster_url gf_film left join gf_film_poster on gf_film.film_id=gf_film_poster.film_id
i getting these results database
film_id,film_name,date,month_ori,month,year,film_release_date, film_feature,film_modify,film_post_link,website_poster_url
so need column contain actors name , actor_id in 1 row related each movies joing above query gf_actor , gf_film_actor
select gf_film.film_id , film_name , date_format(film_release_date,'%d') date , date_format(film_release_date,'%m') month_ori, date_format(film_release_date,'%m') month , date_format(film_release_date,'%y') year , film_release_date , film_feature , film_modify , film_post_link , website_poster_url , group_concat(gf_actor.actor_name) actors gf_film left join gf_film_poster on gf_film.film_id=gf_film_poster.film_id left join gf_film_actor on gf_film_actor.film_id = gf_film.film_id left join gf_actor on gf_film_actor.actor_id = gf_actor.actor_id group gf_film.film_id
Comments
Post a Comment