2021-03-02

select a.dept_name,a.`name`,a.dept_id, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

select a.dept_name,a.`name`, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

SELECT @@GLOBAL.sql_mode;

?set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

? select max(id) as id,name from tbl_employee group by name;

explain Select? distinct st.name from tbl_middle_student st left join tbl_middle_score sc on? st.id = sc.stu_id where sc.score = 100 order by st.name;

select name from tbl_middle_student where id in( select distinct(stu_id) from tbl_middle_score sc where sc.score = 100);

select name from tbl_middle_student st where EXISTS (select distinct(stu_id) as id from tbl_middle_score sc where sc.score = 100 and st.id = sc.stu_id);

select * from tbl_employee;

select * from tbl_department;

select a.dept_name,a.name, a.dept_id, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

select a.dept_name,a.`name`,a.dept_id, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

select a.dept_name,a.`name`, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

SELECT @@GLOBAL.sql_mode;

?set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

select dept_id,max(salary) from tbl_employee emp group by emp.dept_id;

select emp.dept_id,max(salary) as '薪資' from tbl_employee emp left join tbl_department depart on depart.dept_id =?

emp.dept_id

?group by emp.dept_id;


?select a.dept_name,emp.name, m.salary from (select emp.dept_id,max(salary) as 'salary' from tbl_employee emp left join tbl_department depart on depart.dept_id =?

emp.dept_id

?group by emp.dept_id) m right join tbl_department a on? a.dept_id = m.dept_id

left join tbl_employee emp on emp.salary = m.salary;


?select a.dept_name,emp.name, m.salary from (select info.dept_id,info.dept_name from tbl_department info)a


?select info.dept_id,info.dept_name,emp.name from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id



?select emp.name,max(salary) from tbl_employee emp left join tbl_department depart on depart.dept_id =?

emp.dept_id

?group by emp.dept_id;



?select emp.name,depart.dept_name,emp.dept_id, max(salary) from tbl_employee emp left join tbl_department depart on depart.dept_id =?

emp.dept_id

?group by emp.dept_id;


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一 介紹本節(jié)主題 多表連接查詢復(fù)合條件連接查詢子查詢準(zhǔn)備表 建表 create table department(...
    wujimozun閱讀 243評(píng)論 0 0
  • @[TOC] 1.準(zhǔn)備表 2. 多表連接查詢 交叉連接:不適用任何匹配條件。生成笛卡爾積mysql> select...
    態(tài)度哥閱讀 167評(píng)論 0 0
  • 查看當(dāng)前所有存在的數(shù)據(jù)庫(kù) SHOW DATABASES; 創(chuàng)建測(cè)試數(shù)據(jù)庫(kù)test_db CREATE DATABA...
    頂寶麻麻閱讀 308評(píng)論 0 0
  • 一、SQL速成 結(jié)構(gòu)查詢語(yǔ)言(SQL)是用于查詢關(guān)系數(shù)據(jù)庫(kù)的標(biāo)準(zhǔn)語(yǔ)言,它包括若干關(guān)鍵字和一致的語(yǔ)法,便于數(shù)據(jù)庫(kù)元件...
    shadow雨軒閱讀 577評(píng)論 0 3
  • title: "Oracle創(chuàng)建表空間和表"date: 2021-02-01T20:17:20+08:00draf...
    大地缸閱讀 275評(píng)論 0 0

友情鏈接更多精彩內(nèi)容