码迷,mamicode.com
首页 > 数据库 > 详细

mysql 库表整体相关查询

时间:2019-08-10 19:26:26      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:多少   orm   smis   order   mat   count   name   hang   pre   

select table_schema,table_name from information_schema.columns where column_name = '字段名';
  • 查询某张表有几条记录
select count(*) FROM gasmis_shangxian.his_fuel_record;
  • 查询某几张表一个有多少条记录
SELECT SUM(a) from(SELECT COUNT(*) a FROM gasmis_shangxian.his_fuel_record
UNION
SELECT COUNT(*)a FROM gasmis_shangxian.his_account_journal
UNION
SELECT COUNT(*) a FROM gasmis_shangxian.his_oilsys_fuel_record) as aa
  • 查询某个字段属于哪个库
- > select table_schema,table_name from information_schema.columns where column_name = '字段名'
  • 批量更新某个主键,使其值增1,直接update会主键冲突,使用order by (神奇的order by 用法)
UPDATE normalflow_list
SET flow_seqno = flow_seqno + 1
WHERE
    flow_id = '010101'
AND flow_seqno > 2
ORDER BY
    flow_seqno DESC;
  • 获取某一列的最大值

    select max(volumu) from table_name
    
    select max(flow_seqno) from normalflow_list where flow_id = '010101';

mysql 库表整体相关查询

标签:多少   orm   smis   order   mat   count   name   hang   pre   

原文地址:https://www.cnblogs.com/sfth/p/11332532.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!