mysql - Excude value from sql results -
here problem.i have table recursive association this:(#id_boss,#id_manager) references id_employee.
i have function $id argument .in function have sql query should return id_boss or id_manager depending on $id.
this query:
select group_concat (id_guy, id_friend) table id_guy=$id || id_friend=$id;
my query works returns $id value (because id_guy $id_friend $id_guy) exclude.
example:
- $id_guy=10, id_friend=11
- $id_guy=14, id_friend=10
i have result: 11,14 , not: 10,11,14,10
how that?
thanks
group_concat()
ignores null
values, can use case
in select
:
select group_concat((case when id_guy <> $id id_guy end), (case when id_friend <> $id id_friend end) ) table $id in (id_guy, id_friend);
edit:
the above might require else
:
select group_concat((case when id_guy <> $id id_guy else '' end), (case when id_friend <> $id id_friend else '' end) ) table $id in (id_guy, id_friend);
Comments
Post a Comment