troubleshooting Question

How to select record with In and condition together based on more then one coulmn

Avatar of Parm singh
Parm singh asked on
MySQL Server
7 Comments1 Solution170 ViewsLast Modified:
I trying to get some thing like this if same uid have pid 36 and oid = 940 as passed in query then need to select other record with same pid and uid with other oid as shown following, But if this uid 1138 and pid - 36 does not have oid 940 then it should not show other two record also

org pid uid  oid
938 36  1138 938
938 36  1138 940
938 36  1138 941

I am doing some thing like this But doesn't get logic how it will work

SELECT     DISTINCT user_org.oid org,
           pid,
           user_users.uid,
           acl_user_perms.oid
FROM       `acl_user_perms`
INNER JOIN user_users USING(uid)
INNER JOIN user_org
ON         (user_users.oid = user_org.oid)
INNER JOIN user_org_admin
ON         (user_org.oid = user_org_admin.oid)
WHERE      pid = 36
and        value = 1
and        acl_user_perms.oid = 940
and        acl_user_perms.oid IN (938,945,941);
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros