select u.org_id as orgId, u.mobile, o.org_name as orgName from djd_user u inner join sys_org o on u.org_id = o.org_id; 这条SQL能不能改成判断当o.org_name等于指定值时修改u.mobile等于'***'
时间: 2024-04-04 13:35:57 浏览: 89
可以使用以下SQL语句来实现:
UPDATE djd_user u
SET u.mobile = '***'
WHERE u.org_id IN (
SELECT o.org_id
FROM sys_org o
WHERE o.org_name = '指定值'
);
这个SQL语句会在sys_org表中查找org_name等于指定值的记录,并使用INNER JOIN将其与djd_user表中的记录关联。然后使用UPDATE语句将djd_user表中所有org_id等于sys_org表中org_id的记录中mobile字段的值修改为'***'。
相关问题
select u.org_id orgId, u.user_id userId, u.show_order showOrder, u.email, u.status, u.photo, u.lsc, u.office_phone officePhone, u.logon_name logonName, u.global_status globalStatus, u.job_type jobType, u.sex, u.is_mobile_open isMobileOpen, u.job_status jobStatus, u.is_district_leader isDistrictLeader, u.is_mobile_plate_open isMobilePlateOpen, u.user_name userName, u.update_time updateTime, u.is_job_record_tj isJobRecordTj, u.user_job_id userJobId, u.job_position jobPosition, u.old_user_id oldUserId, u.is_home_phone_open isHomePhoneOpen, u.mobile, u.user_res_dep userResDep, u.flag, u.anno, u.is_del isDel, o.org_name orgName from djd_user u inner join sys_org o on u.org_id = o.org_id这样返回到MAP中显示的key都是小写的是为什么?
这是因为在 SQL 查询中使用了小写的列名,导致返回结果中的列名也是小写的。如果想要返回大写的列名,可以在 SQL 查询中使用 AS 关键字来指定别名,例如:
```
SELECT u.org_id AS orgId, u.user_id AS userId, ...
```
这样返回的结果中,列名就会使用别名中指定的大小写形式。
SELECT s.BOOKID as bookid,s.CLASSID as classid, s.GQJ_CLASS as gqjClass,s.GQJ_CLASSIFY as gqjClassify, s.GQJ_STANDARDID as gqjStandardid, s.GQJ_STANDARD as gqjStandard,s.FACTORY_NUM as factoryNum, s.PK_USERLOCALEID as pkUserlocaleid, s.USE_ADDRESS_NAME, s.USE_ORGID as orgid, s.USE_ORG as orgname,s.NEXT_TEST_TIME as nextTestTime, s.CLASSIFYID as classifyid, s.COMMENT_STATUS as commentStatus,s.ISPLAN as isConsumables,1 AS num,1 AS collectedNum,s.I_CODE as iCode,USE_BZID as deptid, USE_BZNAME as deptname FROM gqj_gqjbook s WHERE s.ISPLAN = 0 and USE_RECORD_STATUS="2" and STATUS="0" and (COMMENT_STATUS!='0' or ISNULL(COMMENT_STATUS) or COMMENT_STATUS = '' ) and USE_BZID = '860dc38c2bed4130b3d0746cee8dbf2e' and PK_USERLOCALEID='0346c06203c84e398d3c4381d5b34b7a' and I_CODE IN ( '030080000000000000003134' ) UNION SELECT any_value(s.BOOKID) as bookid,any_value(s.CLASSID) as classid, any_value(s.GQJ_CLASS) as gqjClass, any_value(s.GQJ_CLASSIFY) as gqjClassify, any_value(s.GQJ_STANDARDID) as gqjStandardid, any_value(s.GQJ_STANDARD) as gqjStandard,any_value(s.FACTORY_NUM) as factoryNum, any_value(s.PK_USERLOCALEID) as pkUserlocaleid, any_value(s.USE_ADDRESS_NAME) as useAddressName, any_value(s.USE_ORGID) as orgid, any_value(s.USE_ORG) as orgname, any_value(s.NEXT_TEST_TIME) as nextTestTime, any_value(s.CLASSIFYID) as classifyid, any_value(s.COMMENT_STATUS) as commentStatus,any_value(s.ISPLAN) as isConsumables,COUNT( 0 ) AS num,count(0) AS collectedNum, any_value(s.I_CODE) as iCode, any_value(USE_BZID) as deptid,any_value(USE_BZNAME) as deptname FROM gqj_gqjbook s WHERE s.ISPLAN = 1 and USE_RECORD_STATUS="2" and STATUS="0" and (COMMENT_STATUS!='0' or ISNULL(COMMENT_STATUS) or COMMENT_STATUS = '' ) and USE_BZID = '860dc38c2bed4130b3d0746cee8dbf2e' and PK_USERLOCALEID='0346c06203c84e398d3c4381d5b34b7a' and I_CODE IN ( '030080000000000000003134' ) GROUP BY GQJ_STANDARDID order by any_value(commentStatus), any_value(gqjClass), any_value(gqjClassify), any_value(gqjStandard);
这是一个 SQL 查询语句,用于从 gqj_gqjbook 表中获取符合条件的数据,并按照一定的规则排序。具体的查询条件包括:ISPLAN=,USE_RECORD_STATUS="2",STATUS="",COMMENT_STATUS!='' 或 COMMENT_STATUS 为空,USE_BZID='860dc38c2bed413b3d0746cee8dbf2e',PK_USERLOCALEID='0346c06203c84e398d3c4381d5b34b7a',I_CODE='030080000000000000003134'。如果符合条件,会返回 BOOKID、CLASSID、GQJ_CLASS、GQJ_CLASSIFY、GQJ_STANDARDID、GQJ_STANDARD、FACTORY_NUM、PK_USERLOCALEID、USE_ADDRESS_NAME、USE_ORGID、USE_ORG、NEXT_TEST_TIME、CLASSIFYID、COMMENT_STATUS、ISPLAN、num、collectedNum、I_CODE、deptid、deptname 等字段的值。
阅读全文