根據我所遇到的應用情況,總結了以下3中簡單的語句
1. select *,(select field from table t2 order by field) s from table t1
2. select t1.* from table t1 where t1.field=(select min(t2.field) from table t2 )
3. select * from table t1 where not exists(select 1 from table t2 where t1.id= t2.id and t1.filed> t2.filed) limit 1
效率沒有專門去測試過,大致2>3>1
適用多表連線或者group無排序情況
歡迎補充互相學習
MySQL 模糊查詢某字段用逗號隔開
1.查詢pnum欄位中包含3或者9的記錄 select from test where find in set 3 pnum or find in set 9 pnum select from test where concat pnum,regexp 0 9 3 9 0 9 2.cover欄位為 ...
MySQL 模糊查詢某字段用逗號隔開
1.查詢pnum欄位中包含3或者9的記錄 select from test where find in set 3 pnum or find in set 9 pnum select from test where concat pnum,regexp 0 9 3 9 0 9 2.cover欄位為 ...
mysql 按值查詢與替換欄位中的某字
mysql 按值查詢 update 表名 set 欄位名 設定值 where cslx 原始值 替換欄位中的某字 msql裡面的某個表的某個字段裡面儲存的是乙個人的位址,有一天這個位址的裡面的某個地 比如 原來是 number addr 01 四川省成都市 街道05號 02 四川省成都市 街道07號...