真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

mysql中入門語句的示例分析

這篇文章主要為大家展示了“MySQL中入門語句的示例分析”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“mysql中入門語句的示例分析”這篇文章吧。

成都地區(qū)優(yōu)秀IDC服務(wù)器托管提供商(創(chuàng)新互聯(lián)建站).為客戶提供專業(yè)的遂寧聯(lián)通機(jī)房,四川各地服務(wù)器托管,遂寧聯(lián)通機(jī)房、多線服務(wù)器托管.托管咨詢專線:18982081108

Select,Left Join的用法,及模糊查詢的實現(xiàn):

LEFT JOIN 關(guān)鍵字會從左表 (table_name1) 那里返回所有的行,即使在右表 (table_name2) 中沒有匹配的行。
(業(yè)務(wù)需求:從一張表查詢出來的數(shù)據(jù)要關(guān)聯(lián)到另一個表,并實現(xiàn)模糊查詢)

const sql = `select cei.intentionID,cei.engineerName,cei.nickname,cei.headImgUrl,
ifnull(cmw.headImgUrl,'') inviteImgUrl,ifnull(cmw.nickname,'') inviteNickName
from cm_engineer_intentions cei
left join cm_member_wechats cmw on cmw.referralCode=cei.inviteCode
where (:isGrant=-1 or isGrant=:isGrant)
and (:intentionStatus=-1 or intentionStatus=:intentionStatus)
and (:searchKey='' or concat(engineerMobile,engineerName) like concat('%',:searchKey,'%'))
order by intentionStatus asc,createTime desc`;

Update Set的用法

(業(yè)務(wù)需求:當(dāng)某個字段有傳進(jìn)來時就更新,沒有傳進(jìn)來時忽略,這樣可以根據(jù)你的需求來選擇是否插入某個字段)

const contactRemarkSql = isUpdateRemark ? ',contactRemark=:contactRemark' : '';
const sql = `update cm_engineer_intentions
set intentionStatus=:intentionStatus ${contactRemarkSql}
where intentionID=:intentionID`;

Delete,In的用法:(IN 操作符允許我們在WHERE子句中規(guī)定多個值)

下面的SQL語句可以刪除多條符合條件的數(shù)據(jù)
(業(yè)務(wù)需求: 進(jìn)行刪除操作時,創(chuàng)建數(shù)據(jù)的人若是操作數(shù)據(jù)的人,則刪除,否則更新狀態(tài))
const deleteSql = delete from cm_fast_order_goods where orderGoodsID in (${deleteData.deleteIDs}) and createUser=:userName;
const updateSql = update cm_fast_order_goods set status=0 where orderGoodsID in (${deleteData.deleteIDs}) and createUser!=:userName;

Insert的用法

(業(yè)務(wù)需求:新增一條新的數(shù)據(jù))

const sqlOrderEngineer = `insert into cm_order_engineers
(orderEngineerID,orderGoodsID,orderID,engineerID,engineerName,createUser,createTime)
values
(:orderEngineerID,:orderGoodsID,:orderID,:engineerID,:engineerName,:createUser,:createTime)

(業(yè)務(wù)需求:每新增一條數(shù)據(jù),某一字段在原有的數(shù)據(jù)的最大值基礎(chǔ)上+1)

const sql = `insert into cm_engineers
(engineerCode,loginName,password,engineerName,sex,birthDate,status,createUser,createTime)
select                            
ifnull(max(engineerCode),0)+1,:loginName,:password,:engineerName,:sex,:birthDate,
:status,:createUser,now()
from cm_engineers`;

(業(yè)務(wù)需求:從其他表中新增數(shù)據(jù)到當(dāng)前表)

insert into cm_fast_order_goods (orderGoodsID,orderID,goodsID,goodsCode,goodsPicUrl,createUser,createTime)
select :orderGoodsID,:orderID,:goodsID,goodsCode,iconUrl,:createUser,now()
from cm_service_goods
where goodsID=:goodsID and status=1

以上是“mysql中入門語句的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


網(wǎng)頁題目:mysql中入門語句的示例分析
當(dāng)前地址:http://weahome.cn/article/ijijdo.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部