【发布时间】:2015-10-15 21:03:03
【问题描述】:
我有两张表,都只有一列。
Table 1: Merchants
Column: merchant (20 entries)
Table 2: Categories
Column: category (600 entries)
我正在尝试编写一个 for each 循环来选择这两个表中的所有条目并以这种格式列出所有可能的组合。比如……
merchant1 category1
merchant1 category2
merchant1 category3... all the way to end of categories
merchant2 category1
merchant2 category2
merchant2 category3...all the way to end of categories
etc...
我应该使用一个 mysql 命令来选择数据,然后使用 for each 循环?...还是应该运行 2 个 mysql 命令并在多个数组上使用嵌套的 for 每个循环?
【问题讨论】:
-
使用全外连接取表的叉积
-
你能给我看一个代码示例吗?
-
抱歉,这不是很有建设性,但我想说“六个中的六个”。
标签: php mysql loops foreach while-loop