Breka Posted May 15, 2009 Share Posted May 15, 2009 Hello All, I have a problem that I can solve mathematically but is rather difficult in MySQL world. Here is the issue: I have a table that looks like the following: | label_a | label_b | label_c | label_d | | a | NULL | NULL | NULL | | NULL | b | NULL | NULL | | NULL | NULL | c | NULL | | NULL | NULL | NULL | d | and I want it to look like the following: | label_a | label_b | label_c | label_d | | a | b | c | d | Any thoughts? I really want to stay away from subqueries as the tables are relatively massive. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/158294-transforming-a-table/ Share on other sites More sharing options...
fenway Posted May 15, 2009 Share Posted May 15, 2009 What do those rows represent? Quote Link to comment https://forums.phpfreaks.com/topic/158294-transforming-a-table/#findComment-834978 Share on other sites More sharing options...
Breka Posted May 15, 2009 Author Share Posted May 15, 2009 The rows are the result of an executed query. I was hoping that there was some manner of transformation on the result set that didn't involve manipulation of the original query whatsoever. For example, mathematically, I'd look at multiplying the matrix on the left by a n x 1 row vector of 1's to produce a n x 1 vector of values. Quote Link to comment https://forums.phpfreaks.com/topic/158294-transforming-a-table/#findComment-835006 Share on other sites More sharing options...
fenway Posted May 19, 2009 Share Posted May 19, 2009 Hmm... COALESCE() will return the first non-null value it finds, but that would mean you'd need to get the rows "joined" together first. Quote Link to comment https://forums.phpfreaks.com/topic/158294-transforming-a-table/#findComment-837170 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.