我有两个名为oc_users和oc_groups的表,两个表之间没有特定的关系,如下所示,因此,在这里,我想将每个用户映射到每个组:

1)表1:
从oc_users中选择uid;

+-----------------+
| uid             |
+-----------------+
| [email protected]   |
| pankaj          |
| sumit           |
+-----------------+


2)表2:
从oc_groups中选择gid;

+---------+
| gid     |
+---------+
| qlc     |
| qlc-web |
+---------+


然后我想像这样的o / p:

+---------+-----------------+
| gid     | uid             |
+---------+-----------------+
| qlc     | [email protected]   |
| qlc     | pankaj          |
| qlc     | sumit           |
| qlc-web | [email protected]   |
| qlc-web | pankaj          |
| qlc-web | sumit           |
+---------+-----------------+

最佳答案

用这个

select * from oc_user , oc_groups ORDER BY gid, uidS


这将用Cartesian multiplecation of rows.打印所有列

10-05 20:37