ppts.net
当前位置:首页>>关于MYSQL 按字段 A 查询,此表中字段 A 重复的话,字...的资料>>

MYSQL 按字段 A 查询,此表中字段 A 重复的话,字...

select 字段A,sum(字段B) from 表A group by 字段A order by 字段A你试试这个

可以先关联表把重复的数据提取出来,然后通过表主键进行删除操作,例如 delete from B表where B表主键ID IN(select b.B表主键ID from B表 b inner join A表 a on b.b1=a.a1)

select t1.a , (select top 1 t2.b from table2 as t2 where t2.b = t1.a and 额外条件1) as 对应于额外条件的列名1, (select top 1 t2.b from table2 as t2 where t2.b = t1.a and 额外条件2) as 对应于额外条件的列名2, (select top 1 t2.b fr...

select * from A where A.cat_id in (13,14);

SELECT * FROM names;+----+--------+| id | name |+----+--------+| 1 | google || 2 | yahoo || 3 | msn || 4 | google || 5 | google || 6 | yahoo | 想保留最大id的话: DELETE FROM NAMES WHERE id NOT IN (SELECT * FROM (SELECT MAX(n.id...

create table B LIKE A 这种方法建立,会不带任何数据,但是会带着表A的主键,约束等 create table B select * from A 这种方法建立,会带着数据,但是不会带着表A的主键,约束等

select a+b from 表

按每天每小时分组就好了 select (atype+s_set) as sum from tablename group by date,hour

试试这个方法:SELECT id, name, (SELECT comment_id, title, content FROM B WHERE user_id = A.id ORDER BY create_time DESC LIMIT 1) FROM A;

select * from 表A as A left join 表B as B on A.a=B.a

网站首页 | 网站地图
All rights reserved Powered by www.ppts.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com