(CNN)Serious infections during childhood have been tied to a subsequent increased risk of mental disorders in a new study.

The study, published in the journal JAMA Psychiatry on Wednesday, found that infections requiring hospitalizations were associated with an about 84% increased risk of being diagnosed with any mental disorder and an about 42% increased risk of using psychotropic drugs to treat a mental disorder.

Less severe infections treated with anti-infective medications, like antibiotics, were associated with increased risks of 40% and 22%, respectively, the study found.

“The surprising finding was that the infections in general — and in particular, the less severe infections, those that were treated with anti-infective agents — increased the risk for the majority of mental disorders,” said Dr. Ole Köhler-Forsberg, a neuroscientist and doctoral fellow at Aarhus University in Denmark, who led the study.

Yet he emphasized that the study found only a correlation, so the findings do not mean that infections, or receiving treatment for them, can cause mental disorders.

“Parents should not be afraid when their children get sick or when they need antibiotics,” Köhler-Forsberg said.

“Infections per say are not bad. People need infections to develop the immune system, but in some cases, the infection can increase the risk for a mental disorder,” he said. “The overall take-home message is that there’s an intimate connection between the body, the immune system, infections, inflammation and the brain.”

For the study, Köhler-Forsberg and his colleagues analyzed health data on more than 1 million people born in Denmark between 1995 and 2012, taking a close look at their medical histories from birth to late adolescence.

The data came from two registries: the Danish National Patient Registry and the Danish National Prescription Registry.

The researchers found associations between any treated infection and the increased risk of later being prescribed medication for various childhood and adolescent mental disorders, with the risks differing for specific disorders.

“To our knowledge, the present study is the first to indicate that any treated infection, including less severe infection, is associated with an increased risk of a wide range of childhood and adolescent mental disorders,” they wrote.

The study has some limitations, including that the data was analyzed only up to age 18, and there was no way to confirm that patients really had infections versus being misdiagnosed.

Additionally, because the study was registry-based and observational, “we can not conclude any causality. So we can not say this infection led to this mental disorder. So we can only speculate,” Köhler-Forsberg said.

“Our findings, at least to some part, can also be explained by other things like genetics or socioeconomic status,” he said. “Those are things that we try to adjust for, but it’s never possible to adjust for everything in these studies.”

So more research is needed to determine the exact mechanism behind the complex link between infections and mental disorders.

“Mostly, if you take somebody with a mental disorder — anxiety, depression, schizophrenia — and look at their rate of inflammation, it’s likely to be higher. There’s likely to be inflammatory cytokines involved in that disorder, and we don’t understand why,” said William Eaton, a professor of mental health at Johns Hopkins Bloomberg School of Public Health, who was not involved in the study but has conducted separate research with some of the authors.

Pro-inflammatory cytokines are molecules involved in the body’s inflammatory reactions. Higher rates of such molecules or some type of immune dysfunction may help explain the link between infections and mental disorders, but more research is needed.

Other hypotheses, noted in the study, include that some infections might enter the brain and influence neurological processes or that treatment for infections might alter the gut microbiome — the ecosystem of bacteria and other microorganisms — and this disturbance may impact the brain.

“There are many studies now on mental disorders and inflammation and immunity,” Eaton said.

“The immune processes involved in mental disorders are terribly important because if we could understand them we might be able to prevent or better treat disorders — and we don’t have quite enough understanding to do that yet,” he said.

Dr. Lena Brundin and Viviane Labrie, both investigators at the Van Andel Research Institute in Michigan, co-authored an editorial that accompanied the new study in JAMA Psychiatry on Wednesday. They called the findings “compelling.”

“The results of the Danish study leave a number of pressing questions. Since the study controlled for important confounders and validated the findings in a sibling cohort, the results may reflect a causative biological mechanism. What could this mechanism be? More importantly, could we reduce the incidence of debilitating childhood neuropsychiatric disorders by targeting infection?” Brundin and Labrie wrote.

“Disease onset appears to be soon after exposure, because the biggest increase in risk was observed 0 to 3 months after infection,” they wrote. “These results bring a sense of urgency to detailing the underlying mechanisms of this association, in particular because of the possibility that these severe and occasionally permanent neuropsychiatric conditions might be rapidly recognized and treated by pharmacological compounds already in clinical use.”