mySQL UNION 연산 자의 기본 규칙 연구
                                            
 3258 단어  SQLUNION 연산 자
                    
 
/*       */ 
create table td_base_data( id int(10) not null auto_increment,userId int(10) default '0',primary key (`id`))ENGINE=MyISAM DEFAULT CHARSET=gbk; 
create table td_base_data_20090527( id int(10) not null auto_increment,userId int(10) default '0',primary key (`id`))ENGINE=MyISAM DEFAULT CHARSET=gbk; 
/*        */ 
insert into td_base_data(userId) values(1); 
insert into td_base_data(userId) values(45); 
insert into td_base_data(userId) values(45); 
insert into td_base_data(userId) values(1); 
insert into td_base_data(userId) values(45); 
insert into td_base_data_20090527(userId) values(1); 
insert into td_base_data_20090527(userId) values(45); 
insert into td_base_data_20090527(userId) values(45); 
insert into td_base_data_20090527(userId) values(1); 
insert into td_base_data_20090527(userId) values(45); 
insert into td_base_data_20090527(userId) values(45); 
/*      */ 
select count(userId) as cnumber from td_base_data where userId = '45'; 
/* 3 */ 
select count(userId) as cnumber from td_base_data_20090527 where userId = '45'; 
/* 4 */ 
select (select count(userId) from td_base_data where userId = '45') + (select count(userId) from td_base_data_20090527 where userId = '45') as cnumber; 
/* 7 */ 
select count(*) from 
( 
select id from td_base_data where userId = '45' 
union 
select id from td_base_data_20090527 where userId = '45' 
) as tx; 
/* 4 */ 
select count(*) from 
( 
select * from td_base_data where userId = '45' 
union 
select * from td_base_data_20090527 where userId = '45' 
) as tx; 
/* 4 */ 
/*    mysql ,union            */ 
/*        */ 
/* 
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Redash를 사용할 때 몰랐던 SQL을 쓰는 법을 배웠습니다.최근 redash에서 sql을 쓸 기회가 많고, 이런 쓰는 방법이 있었는지와 sql에 대해 공부를 다시하고 있기 때문에 배운 것을 여기에 씁니다. Redash란? 월별로 데이터를 표시하고 싶습니다 주별로 데이터를 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.