我需要用外行的语言进行反击。
SELECT
t1.*
, IF(isBranch='true','',IF(pointsweightage IS NULL,'Not Set',pointsweightage)) AS w
, t2.id AS wid
FROM
`skills_hierarchy` t1 LEFT JOIN
weightage t2 ON t1.pointsweightage=t2.weightage
WHERE
isBranch='false'
AND t1.deptid=$deptid
AND t2.deptid=$deptid
我想要更改查询,以便它获取它登录的部门的数据。
答案 0 :(得分:1)
好吧,我会重新格式化一下来帮助你,然后我会在下面解释。
SELECT
t1.*,
IF(isBranch='true',
'',
IF(pointsweightage IS NULL,
'Not Set',
pointsweightage)) AS w,
t2.id AS wid
FROM `skills_hierarchy` t1
LEFT JOIN weightage t2
ON t1.pointsweightage=t2.weightage
WHERE isBranch='false'
AND t1.deptid=$deptid
AND t2.deptid=$deptid
“选择”部分从“skills_hierarchy”表中获取所有值,然后获取名为“w”的列的值。这个值将是三件事之一。
查询已根据$ deptid
的参数值过滤掉结果