mysql - How to workaround selecting multiple columns inside a single case expression -
I am thinking that if there is a way to select two columns based on the outcome of a statement.
Even so I have so far (I have reduced half the amount of unnecessary stuff):
(Select IF (Select user. I.I. (G.ID = u.group_id) WHERE u.id = 2)> = 4, (SELECT p.action, p.id permissions as p, WHERE p.required_points & lt; = ( Choosing reputation from users WHERE id = 2)), (SELECT 0, 0))) In fact, is there any number of columns operands that behave like statements? And if so, how do I apply them?
1241 - Operand must have 1 column (s)
Entire SQL query:
(SELECT p1.action, user_primation from p1.id Add permissions as AS u1 INNER P1 ON (P1id = u1.action_id) WHERE u1.user_id = 2) Union (SELECT p2 .action, p2.id users by U2Inner User User Group AG on (live) .ID = U2Grap_ID) Join Inner GOP On (GPIGP.Group_ID = G.Id) Inner P2On (P.ID) = GP.action_id) where U.ID = 2) Unions (selection) Do it U (In the United States user group ASG2 ON (G.ID = U3 NCHGID) where U 3. id = 2)> = 4, (SELECT p3.action , P3.id permissions from p3 WHERE p3.required_points & lt; = (select reputation users from WHERE id = 2)), (SELECT 0, 0)))
Oh, this is basically the entire query. It will not work:
Select (SELECT g2. Id users from U3 Inner UserGroup ASG2 ON G 2.ID = u3.group_id WHERE U.ID = 2) & gt; = 4, (SELECT p3.action, p3.id permissions from p3 WHERE p3.required_points & lt; = (select reputation users WHERE id = 2)), (SELECT 0, 0))) Therefore, just move from one to for the clause: SELECT (in case when g2.id> = 4, p3.action, 0), (Case when g2.id> = 4, p3.id, 0) (Select from users g2.id as 3 of these user groups on G2 g2.id = u3.group_id WHERE u3 .id = 2) G2 Cross Join (P3.action, p3.id from permissions from p3 WHERE p3.required_points & lt; = (selection of prestige users WHERE id = 2))) P 3 If you really do not want to have row with (0, 0) , but this is just what some other value is, then Join or where filter it: SELECT p3.action, p3.id FROM (SELECT p3.action, p3.id permissions, p3 WHERE P3 .required_points & lt; = (selection of users where ID = 2)) P3 where users (user by these user user user group ASG2 ONG 2.ID = u3.group_id WHERE U.ID = 2) & gt; = 4
Comments
Post a Comment