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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left Join?

Status
Not open for further replies.

macubergeek

IS-IT--Management
Dec 29, 2004
41
US
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.


 
how bout....

Code:
select count(risk) as "Subtotals:",label as "Risk Level" from results,risklabel WHERE risk = riskID group by risk;
 
Thanks
it was the Where statement I was messing up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top