mysql查询高级用法
时间:2021-07-01 10:21:17
帮助过:28人阅读
select a.
* , b.adress , b.name
from a , b
where a.sbNo
= b.cdid
order by a.sbNo , a.STime
select a.a_id, a.a_name, b.b_name from A a, B a where a.b_id = b.b_id //联合查询
insert into table1 (xx,yy,zz)
select xx,yy,zz
from table2;
select axx
as id, att
as name
from tb1
union
select bxx
as id, btt
as name
from tb2
整合有关联的两个数据表里的字段
update TableA
AS ta, TableB
AS tb
SET ta.field1
= tb.field1
WHERE ta.id
= tb.ta_id
//经典案例
(新用户)通过表A获取的记录集,如下:
1 2012-11-1
3 2012-11-2
8 2012-11-5
(老用户)通过表B获取的记录集,如下:
5 2012-11-1
3 2012-11-2
我想将这两个结果集合并为一个结果集。显示的结果如下:
日期 新用户 老用户
2012-11-1 1 5
2012-11-2 3 3
2012-11-5 8 0
select a.col2, a.id, ifnull(b.id,
0)
from newuser a
left join olduser b
on a.col2
=b.col2;
http://www.cnblogs.com
/JuneZhang
/archive
/2010/08/26/1809306.html
mysql查询高级用法
标签:date www select ble 查询 name weight user 通过