各種MySQL混亂操作

2021-06-14 12:19:58 字數 4062 閱讀 5315

-- 多資料插入表

insert into es_status_s (touroperator, iff_objektlog, iff_mit_describe, iff_ohne_describe)

values ('jum', (select number from jumpreview where id like '2'),

(select number from jumpreview where id like '7'),

(select number from jumpreview where id like '6') );

-- 插入另一表的統計資料

insert into jumpreview

select '5', count(distinct leistungscodierung) , 'offer without describe'

from jumnodescribe_accomcode;

-- 選擇資料插入其他的表

insert into `ctrip_master_hotel`

(`id`,`name`,`nameen`,`city`,`cityen`,`country`,`countryen`,`address`,`addressen`,`fr_hotelid`,`description`)

select `masterhotelid_ctrip`,`hotelname_zhcn`,`hotelname`,`city_zhcn`,`city`,`country_zhcn`,`country`,`address_zhcn`,`address`,`hotelid_fr`,`description_zhcn`

from `fr_hotel_zhcn`

新建表 create

drop table if exists jumpreview;

-- 使用 union 得到不同表的資料,建立新錶

create table jumpreview

select "1" as 'id', count(*) as 'number' , 'count objektlog_es' as explaination from objektlog_es where veranstalter='jum'

union

select "2", count(distinct iff), 'number of iff in objektlog_es' from objektlog_es where veranstalter='jum' and iff<>0 and iff<>888888 and iff is not null

union

select "3", count(*) , 'count hotelinfo' from hotelinfoboxvacrs where touroperator='jum'

union

select "4", count(distinct iff) , 'number of iff in hotelinfo' from hotelinfoboxvacrs where touroperator='jum' and iff<>0 and iff<>888888 and iff is not null;

#accomcode in objectlog not in hotelinfoboxvacrs

drop table if exists jumnodescribe_accomcode;

create table jumnodescribe_accomcode select distinct objektlog_es.leistungscodierung , objektlog_es.iff

from objektlog_es left join hotelinfoboxvacrs 

on hotelinfoboxvacrs.touroperator = objektlog_es.veranstalter and hotelinfoboxvacrs.accomcode = objektlog_es.leistungscodierung

where objektlog_es.veranstalter='jum' and hotelinfoboxvacrs.accomcode is null;

#iff in objectlog not in hotelinfoboxvacrs

drop table if exists jumnodescribe_iff;

create table jumnodescribe_iff select distinct objektlog_es.leistungscodierung , objektlog_es.iff

from objektlog_es left join hotelinfoboxvacrs 

on hotelinfoboxvacrs.touroperator = objektlog_es.veranstalter and hotelinfoboxvacrs.iff = objektlog_es.iff

where objektlog_es.veranstalter='jum' and objektlog_es.iff is not null and hotelinfoboxvacrs.iff is null ;

#offer without describe, not send by tour oeprator

insert into jumpreview select '5', count(distinct leistungscodierung) , 'offer without describe' from jumnodescribe_accomcode;

#iff without describe,

insert into jumpreview select '6', count(distinct iff), 'iff without describe' from jumnodescribe_iff;

/*select distinct objektlog_es.iff

from objektlog_es left join hotelinfoboxvacrs 

on hotelinfoboxvacrs.touroperator = objektlog_es.veranstalter and hotelinfoboxvacrs.iff = objektlog_es.iff

where objektlog_es.veranstalter='jum' and objektlog_es.iff is not null and hotelinfoboxvacrs.iff is null ;

*/#iff with describe

insert into jumpreview select '7', (select number from jumpreview where id like '2') - (select number from jumpreview where id like '6'), 'iff with describe'; 

/*select distinct objektlog_es.iff

from objektlog_es left join hotelinfoboxvacrs 

on hotelinfoboxvacrs.touroperator = objektlog_es.veranstalter and hotelinfoboxvacrs.iff = objektlog_es.iff

where objektlog_es.veranstalter='jum' and objektlog_es.iff is not null and hotelinfoboxvacrs.iff is not null ;

*/#add status

insert into es_status_s (touroperator, iff_objektlog, iff_mit_describe, iff_ohne_describe) 

values ('jum', (select number from jumpreview where id like '2'),(select number from jumpreview where id like '7'), (select number from jumpreview where id like '6') );

MySQL各種姿勢操作

alter table teacherinfo modify varchar 4 after birthday alter table teacherinfo change column num t id int 10 alter table teacherinfo drop column addr...

mysql使用union順序混亂

使用mysql用union並子集中用order by排序順序會混亂 1.select id from a order by start time asc union all select id from b order by start time desc limit 0,20 這樣的寫法會導致排序...

bug篇 mysql排序混亂問題

上圖所示,明明是按照降序排列的,為什麼會出現這種混亂的排序呢?原因 storehouse no這個欄位在資料庫中儲存的型別是varchar,這種型別的字段,mysql在使用order by進行查詢時,是根據字元進行排序的,第乙個字元大的在前面,依次類推,所以就會出現如上圖的排序。解決 要想得到int...