123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- create or replace view base_category_view as
- select bc3.id,
- bc1.id category1_id,
- bc1.name category1_name,
- bc2.id category2_id,
- bc2.name category2_name,
- bc3.id category3_id,
- bc3.name category3_name,
- bc3.create_time,
- bc3.update_time,
- bc3.is_deleted
- from base_category1 bc1
- inner join base_category2 bc2 on bc2.category1_id = bc1.id and bc2.is_deleted = 0
- inner join base_category3 bc3 on bc3.category2_id = bc2.id and bc3.is_deleted = 0
- where bc1.is_deleted = 0;
- explain select bc3.id,
- bc1.id category1_id,
- bc1.name category1_name,
- bc2.id category2_id,
- bc2.name category2_name,
- bc3.id category3_id,
- bc3.name category3_name,
- bc3.create_time,
- bc3.update_time,
- bc3.is_deleted
- from base_category1 bc1
- inner join base_category2 bc2 on bc2.category1_id = bc1.id and bc2.is_deleted = 0
- inner join base_category3 bc3 on bc3.category2_id = bc2.id and bc3.is_deleted = 0
- where bc1.is_deleted = 0;
- select
- ba.id,
- ba.attribute_name,
- bav.id base_attribute_value_id,
- bav.attribute_id,
- bav.value_name
- from base_attribute ba inner join base_attribute_value bav
- on bav.attribute_id = ba.id and bav.is_deleted = 0
- where ba.category1_id = 2 and ba.is_deleted = 0;
- explain select
- ba.id,
- ba.attribute_name,
- bav.id base_attribute_value_id,
- bav.attribute_id,
- bav.value_name
- from base_attribute ba inner join base_attribute_value bav
- on bav.attribute_id = ba.id and bav.is_deleted = 0
- where ba.category1_id = 2 and ba.is_deleted = 0
- select
- ai.id album_id,
- ai.album_title,
- ai.cover_url,
- ai.include_track_count,
- ai.is_finished,
- ai.status,
- stat.stat_type,
- stat.stat_num
- from album_info ai inner join album_stat stat on stat.album_id = ai.id;
- select
- ai.id album_id,
- ai.album_title,
- ai.cover_url,
- ai.include_track_count,
- ai.is_finished,
- ai.status,
- stat.stat_type,
- stat.stat_num
- from album_info ai inner join album_stat stat on stat.album_id = ai.id
- group by ai.id;
- select if(1=2, 'true', 'false');
- select * from album_stat where album_id = 2;
- select if(stat_type='0401', stat_num, 0) play_stat_num,if(stat_type='0402', stat_num, 0) subscribeStatNum from album_stat where album_id = 2;
- explain select
- ai.id album_id,
- ai.album_title,
- ai.cover_url,
- ai.include_track_count,
- ai.is_finished,
- ai.status,
- max(if(stat.stat_type='0401', stat_num, 0)) playStatNum,
- max(if(stat.stat_type='0402', stat_num, 0)) subscribeStatNum,
- sum(if(stat.stat_type='0403', stat_num, 0)) buyStatNum,
- max(if(stat.stat_type='0404', stat_num, 0)) commentStatNum
- from album_info ai inner join album_stat stat on stat.album_id = ai.id
- group by ai.id;
- explain select
- ai.id album_id,
- ai.album_title,
- ai.cover_url,
- ai.include_track_count,
- ai.is_finished,
- ai.status,
- max(if(stat.stat_type='0401', stat_num, 0)) playStatNum,
- max(if(stat.stat_type='0402', stat_num, 0)) subscribeStatNum,
- sum(if(stat.stat_type='0403', stat_num, 0)) buyStatNum,
- max(if(stat.stat_type='0404', stat_num, 0)) commentStatNum
- from album_info ai inner join album_stat stat on stat.album_id = ai.id
- where ai.user_id = ?
- and ai.album_title like concat('%','世界','%')
- and ai.status = ?
- and ai.is_deleted = 0
- group by ai.id
- order by ai.id desc;
- select
- ti.id track_id,
- ti.track_title,
- ti.cover_url,
- ti.media_duration,
- ti.status,
- stat.stat_type,
- stat.stat_num
- from track_info ti inner join track_stat stat on stat.track_id = ti.id;
- select
- ti.id track_id,
- ti.track_title,
- ti.cover_url,
- ti.media_duration,
- ti.status,
- max(if(stat_type='0701', stat_num, 0)) playStatNum,
- max(if(stat_type='0702', stat_num, 0)) collectStatNum,
- max(if(stat_type='0703', stat_num, 0)) praiseStatNum,
- max(if(stat_type='0704', stat_num, 0)) commentStatNum
- from track_info ti inner join track_stat stat on stat.track_id = ti.id
- group by ti.id
- order by ti.id desc;
- explain select
- ti.id track_id,
- ti.track_title,
- ti.cover_url,
- ti.media_duration,
- ti.status,
- max(if(stat_type='0701', stat_num, 0)) playStatNum,
- max(if(stat_type='0702', stat_num, 0)) collectStatNum,
- max(if(stat_type='0703', stat_num, 0)) praiseStatNum,
- max(if(stat_type='0704', stat_num, 0)) commentStatNum
- from track_info ti inner join track_stat stat on stat.track_id = ti.id and stat.is_deleted = 0
- where
- ti.user_id = 1
- and ti.status = '0501'
- and ti.track_title like concat('%','世界','%')
- and ti.is_deleted = 0
- group by ti.id
- order by ti.id desc;
- select * from album_stat where album_id = 1;
- explain select
- album_id,
- max(if(stat_type='0401', stat_num, 0)) playStatNum,
- max(if(stat_type='0402', stat_num, 0)) subscribeStatNum,
- sum(if(stat_type='0403', stat_num, 0)) buyStatNum,
- max(if(stat_type='0404', stat_num, 0)) commentStatNum
- from album_stat where album_id = 1 and is_deleted = 0;
- explain select
- ti.id track_id,
- ti.track_title,
- ti.media_duration,
- ti.order_num,
- ti.create_time,
- max(if(stat_type='0701', stat_num, 0)) playStatNum,
- max(if(stat_type='0702', stat_num, 0)) collectStatNum,
- max(if(stat_type='0703', stat_num, 0)) praiseStatNum,
- max(if(stat_type='0704', stat_num, 0)) commentStatNum
- from track_info ti inner join track_stat ts on ts.track_id = ti.id and ts.is_deleted = 0
- where ti.album_id = 1 and ti.status = '0501' and ti.is_deleted = 0
- group by ti.id
- order by ti.id asc;
|