mysql database table as a whole related queries

select table_schema,table_name from information_schema.columns where column_name = '字段名';
  • There are a few tables in a query record
select count(*) FROM gasmis_shangxian.his_fuel_record;
  • Query a few tables there are a number of records
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
  • Query a field belong to which library
- > select table_schema,table_name from information_schema.columns where column_name = '字段名'
  • Batch update a primary key, its value is incremented by one, directly to updatebe the primary key conflict, the use of order by (magical order by usage)
UPDATE normalflow_list
SET flow_seqno = flow_seqno + 1
WHERE
    flow_id = '010101'
AND flow_seqno > 2
ORDER BY
    flow_seqno DESC;
  • Gets the maximum value of a column

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

Guess you like

Origin www.cnblogs.com/sfth/p/11332532.html