macubergeek
IS-IT--Management
I have this query against database nessus table results:
select count(risk) as "Subtotals:",risk as "Risk Level" from results group by risk;
select count(risk) as "Subtotals:",risk as "Risk Level" from results group by risk;
and it returns:
Subtotals: Risk Level
36 2
304 3
866 6
3304 7
Now I also have this table risklabel in db results:
riskIK label
1 Serious Risk
2 High Risk
3 Medium Low Risk
4 Low Medium Risk
5 Low Medium Risk
6 Low Risk
Above corresponds to:
mysql> describe risklabel
-> ;
+--------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------------------+------+-----+---------+-------+
| riskID | tinyint(11) unsigned | YES | | NULL | |
| label | varchar(20) | YES | | NULL | |
+--------+----------------------+------+-----+---------+-------+
What I'm trying to do is display the values in risklabel.label instead of the values in the column "Risk Label" above.
I've tried a Join but can't get the syntax right. I'm thinking I want to JOIN this column onto the lefthand side of the original results...
Any suggestions would be appreciated.
select count(risk) as "Subtotals:",risk as "Risk Level" from results group by risk;
select count(risk) as "Subtotals:",risk as "Risk Level" from results group by risk;
and it returns:
Subtotals: Risk Level
36 2
304 3
866 6
3304 7
Now I also have this table risklabel in db results:
riskIK label
1 Serious Risk
2 High Risk
3 Medium Low Risk
4 Low Medium Risk
5 Low Medium Risk
6 Low Risk
Above corresponds to:
mysql> describe risklabel
-> ;
+--------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------------------+------+-----+---------+-------+
| riskID | tinyint(11) unsigned | YES | | NULL | |
| label | varchar(20) | YES | | NULL | |
+--------+----------------------+------+-----+---------+-------+
What I'm trying to do is display the values in risklabel.label instead of the values in the column "Risk Label" above.
I've tried a Join but can't get the syntax right. I'm thinking I want to JOIN this column onto the lefthand side of the original results...
Any suggestions would be appreciated.