MySQL Query question---80 points-including the previous points
This post was last edited by amu1433 on 2015-07-13 12:16:30
The previous issue of this has a problem http://bbs.csdn.net/topics/391071156 re-correction ...
ID name nid
1 Name 1 3
3 Name 1 3
4 Name 1 3
5 Name 1 3
1 Name 1 4
2 Name 1 4
5 Name 1 4
1 Name 1 5
3 Name 1 5
5 Name 1 5
The recordset with Nid equals 3 is 1,2,3,4,5
The recordset with Nid equals 4 is 1,2,5
The recordset with Nid equals 5 is 1,3,5
How to get a common ID of three recordsets
is id=1 and id=5.
------to solve the idea----------------------
Perform
Select UID, group_concat (ID) as ID from Tbl_name GROUP by UID
and read into
$r [3] = explode (', ', ' 1,2,3,4,5 ');
$r [4] = explode (', ', ' 1,2,5 ');
$r [5] = explode (', ', ' 1,3,5 ');
$t = Call_user_func_array (' Array_intersect ', $r);
Print_r ($t);
Array
(
[0] = 1
[4] = 5
)