The prevalence of cancer, diabetes mellitus (DM), and hypertension is increasing in ageing populations. We analyzed the association of DM with cancer and its effects on cancer mortality. The data of 2009–2018 from the Korea National Hospital Discharge In-depth Injury Survey were used; 169,959 adults with cancer as the main diagnosis were identified. The association rule for unsupervised machine learning was used. Association rule mining was used to analyze the association between the diseases. Logistic regression was performed to determine the effects of DM on cancer mortality. DM prevalence was 12.9%. Cancers with high DM prevalence were pancreatic (29.9%), bile duct (22.7%), liver (21.4%), gallbladder (15.5%), and lung cancers (15.4%). Cancers with high hypertension prevalence were bile duct (31.4%), ureter (30.5%), kidney (29.5%), pancreatic (28.1%), and bladder cancers (27.5%). The bidirectional association between DM and hypertension in cancer was the strongest (lift = 2.629, interest support [IS] scale = 0.426), followed by that between lung cancer and hypertension (lift = 1.280, IS scale = 0.204), liver cancer and DM (lift = 1.658, IS scale = 0.204), hypertension and liver cancer and DM (lift = 3.363, IS scale = 0.197), colorectal cancer and hypertension (lift = 1.133, IS scale = 0.180), and gastric cancer and hypertension (lift = 1.072, IS scale = 0.175). DM increased liver cancer mortality (p = 0.000), while hypertension significantly increased the mortality rate of stomach, colorectal, liver, and lung cancers. Our study confirmed the association between cancer and DM. Consequently, a patient management strategy with presumptive diagnostic ability for DM and hypertension is required to decrease cancer mortality rates.