sql - Add blank row to MySQL query results based upon change in column value -


if have typical mysql query such as:

select commentno, createddate, createdtime, text comment 

the results displayed in simple table. possible have mysql format output blank line can inserted results based upon change in column?

so if query above returns following default:

 commentno createddate createdtime text  1         2012-08-02  15:33:27    this.  2         2012-08-02  15:34:40    that.  3         2013-06-30  19:45:48    else.  4         2013-06-30  21:26:01    nothing.  5         2013-06-30  21:26:43    was.  6         2013-07-01  13:40:32    hello.  7         2013-07-01  14:08:25    goodbye. 

is possible insert blank row upon change of column value createddate, get:

 commentno createddate createdtime text  1         2012-08-02  15:33:27    this.  2         2012-08-02  15:34:40    that.   3         2013-06-30  19:45:48    else.  4         2013-06-30  21:26:01    nothing.  5         2013-06-30  21:26:43    was.   6         2013-07-01  13:40:32    hello.  7         2013-07-01  14:08:25    goodbye.   

the above not how data stored in comment table, issue of formatting query output.

or better use bufferedwriter in java?

first, let me type of formatting should done @ application layer , not query.

that said, seems amusing exercise, , isn't hard:

select commentno, createddate, createdtime, text (select c.*, createddate key1, 0 ordering       comment c       union       select c2.*, c.createddate, 1       (select distinct createddate comment c) c left join            comment c2            on 1 = 0      ) c order key1, ordering, id; 

note use of left join in second subquery bring in columns, matches select * in first subquery. however, getting rid of last 2 columns still requires listing of them.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -