mysql遇到的一些常用的查詢小問題

2021-08-07 18:17:22 字數 3209 閱讀 8074

group_concat( distinct (if(t_r.id='2','特殊處理',t_r.data) )), t_s.id

解決辦法 order by 乙個id 保證left join有序 如果oder by後的順序依然有等值的就再加個屬性來排序

update t_target t_tar

left

join

(select

ifnull(sum(ifnull(park_state,0)),0)sm, park_id

from

t_park_state

group

by park_id) r_st on r_st.park_id = e_s.park_id

left

join

t_park t_p on t_p.park_id = e_s.park_id

set

t_tar.empty_num = (ifnull(t_p.total_space,0) - ifnull(r_st.sm,0))

delimiter $$

drop procedure if exists add_col_homework;

create procedure add_col_homework()

begin

if not exists ( select

column_name

from

information_schema.columns

where

1 = 1

and table_name ='t_detail_berth_ordinates'

and column_name ='min_berth_number')

then

alter table `t_detail_berth_ordinates` add column `min_berth_number`

varchar(36);

end if;

end;

call add_col_homework;

$$

select inet_aton('192.168.0.0')
create

table

`t_user5` (

`id`

int(11) not

null auto_increment,

`name`

varchar(45) collate utf8_unicode_ci default

null,

`updatetime` datetime not

null

default

current_timestamp

onupdate

current_timestamp comment '時間隨時更新',

`createtime` datetime not

null

default

current_timestamp comment '時間是建立的時間,不隨時更新',

primary

key (`id`)

) engine=innodb default charset=utf8 collate=utf8_unicode_ci

insert

into test.t_user (id, name) values("1","tom");

insert

into test.t_user (id, name) values("2","jack");

update test.t_user set name ='june'

where id =2;

select * from test.t_user;

mysql一些命令 mysql常用的一些命令

一 授權登入 參考grant all privileges on cacti.to hnf localhost identified by hnf 2014 只給cacti這個資料庫授權 grant all on to root localhost identified by huningfei 只...

Mysql常用的一些方法

1 時間戳轉日期 select from unixtime create time,y m d h i s as date from user where from unixtime create time,y m d h i s curdate group by date order by dat...

mysql 一些常用的命令

mysql 一些常用的命令,至少是以前做專案的時候我常用的 啟動 net start mysql 關閉 mysqladmin u root p shutdown enter 000000 遠端連線 mysql h 192.168.1.2 u admin p enter ufmysql test 判斷...