I have a mysql table that have several records linked to one particular tag. For example, this query
SELECT * FROM table1 WHERE tag = 'tag1'
will return this
equipment_id | tag | acquisition_cost | purchase_date | user
1 tag1 200.05 null null
5 tag1 null 02-02-2012 null
19 tag1 null null jsmith
I would like to combine all the results that have the same tag, and insert into a new table so that I get this:
SELECT * FROM table2 WHERE tag = 'tag1'
equipment_id | tag | acquisition_cost | purchase_date | user
[] tag1 200.05 02-02-2012 jsmith
Any suggestions?
If there is only one value per column per tag then you can use a query like this:
If there is more than one value then I’d highly not recommend collapsing the data like this – you should rethink your design.