Hi,

I have a problem: I am using mysql 4.0.24 and I need to make some reports from a database:

mysql> describe events;

+-------------+------------------+------+-----+---------+----------------+

| Field       | Type             | Null | Key | Default | Extra          |

+-------------+------------------+------+-----+---------+----------------+

| id          | int(10) unsigned |      | PRI | NULL    | auto_increment |

| user_id     | varchar(55)      |      |     | 0       |                |

| dep_id      | int(15)          |      |     | 0       |                |

| event_id   | int(15)          |      |     | 0       |                |

| year        | int(15)          |      |     | 0       |                |

| day         | int(15)          |      |     | 0       |                |

| month       | int(15)          |      |     | 0       |                |

| ev_status   | int(11)          | YES  |     | 0       |                |

| ev_type     | int(11)          | YES  |     | 0       |                |

| ev_priority | int(11)          | YES  |     | 0       |                |

+-------------+------------------+------+-----+---------+----------------+

I need something to get:

| USER_ID | DEP_ID | EV_STATUS = 0 | EV_STATUS = 1 | EV_STATUS = 2 | EV_STATUS = 3 | EV_STATUS = 4 | EV_STATUS = 5 | EV_STATUS = 6 |

user_1 1 COUNT COUNT COUNT COUNT COUNT COUNT COUNT

user_2 1 COUNT COUNT COUNT COUNT COUNT COUNT COUNT

user_3 2 COUNT COUNT COUNT COUNT COUNT COUNT COUNT

.
.
.


The problem is that the way I am getting this now is with a query for each user and for each ev_status and the output is in PHP. Is there a better way to do this ? I am only a beginner in MySQL and want to learn more and improve.


Best regards,
Cristi



Reply via email to