Okay, so I have two tables. Lets call them test2 and test2history.
test2 looks like this:
(source: gyazo.com)
test2history looks like this:
I need to pull multiple cells from table test2 and make them go into one single cell in test2history. The week column from test2 would be set to the value of week in test2history.
The day column from test2 translates to:
On the site that I am working on, when submit is clicked it should pull all cell data from test2 where week is the $_GET['week'] in the URL. Which is easy, I have that. But then, it needs to search the rows that it found and then put the 'map' values whose 'day' value are the same into the corresponding weekday in test2history. Let me stop there because I know this is confusing the way I am explaining it, let me make you a visual:
This is how I need it to work:
The 'total' column in test2history should be set as the sum of the cards from test2 that had that same week number. Which I can do that myself, I just wanted to make sure you understand what is happening.
I have read up on some group_concat() which seems like what I need to be using but I just couldn't find a good explanation that related to what I need it to do. That may not even be what I need.
My query I struggled to write isn't correct in any way shape or form but I tried and I have no idea how go about this one, hopefully one of you guys do. Thanks for your help.
I solved this problem a while back by using GROUP_CONCAT.
UPDATE test2history SET monday = (SELECT group_concat(map, ' ', cards SEPARATOR ', ') FROM test2 WHERE test2.day=1 AND test2.week=$week)
I simply repeated this query for each day.