I have a table like this:
| X | Y | Data |
----------------
| 1 | 2 | Hi |
| 3 | 4 | Hey |
| 1 | 2 | New! |
| 1 | 2 | New! |
| 1 | 2 | New! |
A little back story:
I am trying to create a table (HTML) using the co-ordinates specified in my table with the data in the cell body. Because the data isn’t specifically gotten by myself and comes from the users themselves (Grease monkey script pulling data from the site) I need to group the data by X and Y then group by the Data column and pick out the most occurring one.This is so I get legitimate data as they can spoof the data without me able to do anything about it.
The trouble being is finding a select query that will produce some sort of array like the following from the above table.
Array (
[0] = Array (
'x' => 1,
'y' => 2,
'Data' => "New!"
)
[1] = Array (
'x' => 3,
'y' => 4,
'Data' => "Hey"
)
)
I did try a few variations but none worked so I’m checking here to see if anyone could shed some light on my problem.
Thanks!
Does this work for you?
You may also want to consider creating a view:
Then you can simplify the query: