BackgroundSuicide is a major but preventable public health problem in the world. Mental disorders are related to suicide, and can predict suicidal ideation (SI). This study aims to compare the differences in the prevalence and risk factors of SI among patients with five types of mental disorders. MethodsThis study involved adult inpatients with five types of mental disorders in Beijing Anding Hospital. Text mining was used to extract information from the electronic medical records. We performed the Pearson's Chi-square analysis and multivariable unconditional logistic regression to filter factors to assess odds of SI for each type of mental disorders. ResultsOf the 21,287 participants included, 2,619 had experienced SI. For both sexes, the highest risk of SI was found for patients with recurrent depressive disorder (OR = 7.096; P <.001), followed by patients with depressive episode and bipolar affective disorder when comparing with those with substance use disorder. Gender, age, occupation, drinking, single child, personal relationship, family history of mental disorder, family history of suicide and psychological trauma were associated with SI after adjusting for confounding factors, but the risk factors and their effects in each type were different. LimitationsThe clear causal associations between mental disorders and SI cannot be elucidated. In addition, the ability to study the predictors of SI is constrained by the fact that the sample excluded people who completed suicide. ConclusionsSI is common and distinct strategies should be taken in suicide prevention for patients with different types of mental disorders.