Multimorbidity is characterized by the accrual of two or more long-term conditions (LTCs) in an individual. This state of health is increasingly prevalent and poses public health challenges. Adapting approaches to effectively analyse electronic health records is needed to better understand multimorbidity. We propose a novel unsupervised clustering approach to multiple time-to-event health records denoted as multiple state analysis (MSA). In MSA, patients’ pairwise dissimilarities are computed using patients’ state matrices which are composed of multiple censored time-to-event indicators reflecting patients’ health history. The use of state matrices enables the analysis of an arbitrary number of LTCs without reducing patients' health trajectories to a particular sequence of events. MSA was applied to analyse multimorbidity associated with myocardial infarction using electronic health records of 26 LTCs, including conventional cardiovascular risk factors (CVRFs) such as diabetes and hypertension, collected from south London general practices between 2005 and 2021 in 5087 patients. We identified a typology of 11 clusters, characterised by age at onset of myocardial infarction, sequences of conventional CVRFs and non-conventional risk factors including physical and mental health conditions. Interestingly, multivariate analysis revealed that clusters were also associated with various combinations of socio-demographic characteristics including gender and ethnicity. By identifying meaningful sequences of LTCs associated with myocardial infarction and distinct socio-demographic characteristics, MSA proves to be an effective approach to the analysis of electronic health records, with the potential to enhance our understanding of multimorbidity for improved prevention and management.