Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help displaying records.....

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
been advised to upgrade my mysql platform for some added benefits and have done so. one of the items I was looking at is the "with rollup" feature. definately what i am looking for. now....here's where it might get complicated.

is there a way to only display the records in a manner where as there is only one entry you will display it and not the rollup line (or visa versa) and where there are multiple entries, you display those records and the rollup?

this is to be displayed on my webpage not through mysql window if that helps.

example:

select yr, count(yr) as nr, ocode from table1 where dc=1 group by yr,oc with roll up

displays:

+--------+----+--------+
| yr | nr | ocode |
+--------+----+--------+
| 2004 | 2 | 1 |
| 2004 | 2 | [NULL] |
| 2005 | 2 | 1 |
| 2005 | 1 | 3 |
| 2005 | 3 | [NULL] |
| [NULL] | 5 | [NULL] |
+--------+----+--------+

since there is only one grouping for 2004, i only want to display one record as opposed to the two that are showing

since 2005 has two groupings, i would like to display all three of those records.

so my final display would look like this:

+--------+----+--------+
| yr | nr | ocode |
+--------+----+--------+
| 2004 | 2 | 1 |
| 2005 | 2 | 1 |
| 2005 | 1 | 3 |
| 2005 | 3 | [NULL] |
| [NULL] | 5 | [NULL] |

is this possible?
 
what's about posting this question in the mysql forum?

Cheers.

"Avoid virus, boil your PC 1 min. before use it
 
well...considering i have already pulled my data from the data base and looking now to display via PHP, i thought this was the place to go to do that???
 
since there is only one grouping for 2004, i only want to display one record as opposed to the two that are showing

since 2005 has two groupings, i would like to display all three of those records.

so my final display would look like this:

Well, I understood that you need to correct (or make) another select statment in order to get the desired reulst, but if you already have the correct select statment and you want to show it in a web page then take a look to:


They are good resources for what you are looking for. Very good examples too.

Cheers.

"Avoid virus, boil your PC 1 min. before use it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top