1

I have this query:

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

When I do it I get reptitive information from the table beacons

reptitive info - besides <code>blocksID</code> everything is the same

What I want to get instead - one row with an array of blocks ID: One row with an array of blocks ID - to save time and resources by reptitive results table.

1
  • Could you explain further/clarify? Read this a couple of times and it's very hard to understand what you're actually asking? Commented Sep 4, 2014 at 16:24

2 Answers 2

1

SQL Joins Your question (i think) refers to INNER JOIN, which is shown below (amongst others). It also comes with a little bit of SQL for each one :)

Sign up to request clarification or add additional context in comments.

Comments

0

Look into the INNER JOIN function.

3 Comments

Thank you. now I got this Query: SELECT beacons.*, blocks.ID AS blockID FROM (beacons) LEFT JOIN blocks ON blocks.BeaconID = beacons.ID WHERE beacons.ID = '2' ORDER BY beacons.Minor desc
This query makes many rows with the whole info of the beacon again and again, and for each time the only change is the block ID, instead of this repetitive rows I want an array of all of the block IDs in one line - instead of many rows. is that possible?
You are going to have to format your query results into the desired structure after you retrieve them through your codebase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.