从另一个表查询数组

时间:2014-09-04 16:19:45

标签: mysql sql

我有这个问题:

SELECT `beacons`.*, `blocks`.`ID` AS `blockID` FROM (`beacons`) LEFT JOIN `blocks` ON `blocks`.`StoreID` = `beacons`.`Major` WHERE `beacons`.`Major` = '2' ORDER BY `beacons`.`Minor` desc

当我这样做时,我会从表beacons

中获得重复信息

reptitive info - besides <code>blocksID</code> everything is the same http://oi62.tinypic.com/qnofnt.jpg

我想要的是 - 一行有一个块数组ID: One row with an array of blocks ID - to save time and resources by reptitive results table. http://oi59.tinypic.com/aue1ea.jpg

2 个答案:

答案 0 :(得分:0)

查看INNER JOIN函数。

答案 1 :(得分:0)

SQL Joins您的问题(我认为)是指INNER JOIN,如下所示(其中包括)。它还为每一个提供了一点SQL:)