VIEW `v_ebook_data` AS
select
`t_ebook_data`.`fbookid` AS `fbookid`,
`t_ebook_data`.`fperiodid` AS `fperiodid`,
1 AS `fdevicetype`,
`t_ebook_data`.`ftitlephoto` AS `ftitlephoto`,
`t_ebook_data`.`fformat` AS `fformat`,
`t_ebook_data`.`ffilepath` AS `ffilepath`,
`t_ebook_data`.`ffilesize` AS `ffilesize`,
`t_ebook_data`.`fdataversion` AS `fdataversion`,
`t_ebook_data`.`fdataid` AS `fdataid`
from `t_ebook_data`
where (`t_ebook_data`.`fdevicetype` = 1) union select `t1`.`fbookid` AS `fbookid`,`t1`.`fperiodid` AS `fperiodid`,1 AS `fdevicetype`,`t1`.`ftitlephoto` AS `ftitlephoto`,`t1`.`fformat` AS `fformat`,`t1`.`ffilepath` AS `ffilepath`,`t1`.`ffilesize` AS `ffilesize`,`t1`.`fdataversion` AS `fdataversion`,`t1`.`fdataid` AS `fdataid` from `t_ebook_data` `t1` where ((`t1`.`fdevicetype` = 0) and (not(exists(select 1 from `t_ebook_data` `t2` where ((`t2`.`fdevicetype` = 1) and (`t1`.`fbookid` = `t2`.`fbookid`) and (`t1`.`fperiodid` = `t2`.`fperiodid`)))))) union select `t_ebook_data`.`fbookid` AS `fbookid`,`t_ebook_data`.`fperiodid` AS `fperiodid`,2 AS `fdevicetype`,`t_ebook_data`.`ftitlephoto` AS `ftitlephoto`,`t_ebook_data`.`fformat` AS `fformat`,`t_ebook_data`.`ffilepath` AS `ffilepath`,`t_ebook_data`.`ffilesize` AS `ffilesize`,`t_ebook_data`.`fdataversion` AS `fdataversion`,`t_ebook_data`.`fdataid` AS `fdataid` from `t_ebook_data` where (`t_ebook_data`.`fdevicetype` = 2) union select `t1`.`fbookid` AS `fbookid`,`t1`.`fperiodid` AS `fperiodid`,2 AS `fdevicetype`,`t1`.`ftitlephoto` AS `ftitlephoto`,`t1`.`fformat` AS `fformat`,`t1`.`ffilepath` AS `ffilepath`,`t1`.`ffilesize` AS `ffilesize`,`t1`.`fdataversion` AS `fdataversion`,`t1`.`fdataid` AS `fdataid` from `t_ebook_data` `t1` where ((`t1`.`fdevicetype` = 0) and (not(exists(select 1 from `t_ebook_data` `t2` where ((`t2`.`fdevicetype` = 2) and (`t1`.`fbookid` = `t2`.`fbookid`) and (`t1`.`fperiodid` = `t2`.`fperiodid`)))))) union select `t_ebook_data`.`fbookid` AS `fbookid`,`t_ebook_data`.`fperiodid` AS `fperiodid`,3 AS `fdevicetype`,`t_ebook_data`.`ftitlephoto` AS `ftitlephoto`,`t_ebook_data`.`fformat` AS `fformat`,`t_ebook_data`.`ffilepath` AS `ffilepath`,`t_ebook_data`.`ffilesize` AS `ffilesize`,`t_ebook_data`.`fdataversion` AS `fdataversion`,`t_ebook_data`.`fdataid` AS `fdataid` from `t_ebook_data` where (`t_ebook_data`.`fdevicetype` = 3) union select `t1`.`fbookid` AS `fbookid`,`t1`.`fperiodid` AS `fperiodid`,3 AS `fdevicetype`,`t1`.`ftitlephoto` AS `ftitlephoto`,`t1`.`fformat` AS `fformat`,`t1`.`ffilepath` AS `ffilepath`,`t1`.`ffilesize` AS `ffilesize`,`t1`.`fdataversion` AS `fdataversion`,`t1`.`fdataid` AS `fdataid` from `t_ebook_data` `t1` where ((`t1`.`fdevicetype` = 0) and (not(exists(select 1 from `t_ebook_data` `t2` where ((`t2`.`fdevicetype` = 3) and (`t1`.`fbookid` = `t2`.`fbookid`) and (`t1`.`fperiodid` = `t2`.`fperiodid`))))))