Reputation: 23634
I need the riposte in layman's language.
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
I want the Query to be changed such that it gets me the data of the department which it does login.
Upvotes: 1
Views: 114
Reputation: 63136
Well, I'm going to re-format this a bit to help you out, then I'll explain below.
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
The "Select" portion gets you all values from the "skills_hierarchy" table, then a value for a column called "w". This value will be one of three things.
The query is already filtering out results based on a parameter value of $deptid
Upvotes: 1