常用mysql資料庫的sql命令

2021-09-22 19:37:32 字數 859 閱讀 5502

1 方法一:select cast('123' as signed);

2 方法二:select convert('123',signed);

3 方法三:select '123'+0;

如 : update 表1 set name = (select name from 表1 where id = 2) where id = 1 ;

報 : you can't specify target table '表1' for update in from clause

大意是不能在from字句中使用要更新的目標表』表1』 ,

解決方式在查詢中在包裹一層查詢 :

update 表1 set name = (select name from(select name from 表1 where id = 2)tt ) where id = 1 ;

更新a中與c相同的id的值

update a inner join c on a.id = c.id set a.name = c.name;

json_extract(json_doc, path[, path] ...)

從json文件裡抽取資料。如果有引數有null或path不存在,則返回null。如果抽取出多個path,則返回的資料封閉在乙個json array裡。

如:select json_extract('','$.a') from dual

結果:"1"

取json陣列的值

取c1的值:select json_extract(']}','$.c[0].c1') from dual

mysql查資料庫 mysql檢視資料庫命令

mysql檢視資料庫命令 2012 11 29 19 51 25 標籤 it mysql檢視資料庫命令 開啟的資料庫的命令 mysql use mysql database changed 檢視資料庫的命令 mysql show databases 檢視資料表的詳細結構 mysql desc fun...

mysql資料庫常用SQL語句

1.給資料庫新增乙個字段 alter table pre common member field home 表名 add stickblogs 欄位名 varchar 50 資料型別 2.刪除資料庫的乙個字段 alter table param info 表名 drop column channel...

資料庫常用sql

1.oracle.檢視儲存過程 select from user objects where object type procedure 2.oracle.檢視儲存過程源 select text from user source where name cal bjchmiddata 3.oracle...