Sugar is the enemy. Right? Not always, as it turns out—at least according to a new study, which found it depends on how you consume it.In analyzing data from over half a million people across multiple continents, researchers at Brigham Young University found something unexpected: that sugar consumed through drinks like soda—and even pure fruit juice, which is high in naturally occurring fructose—appeared to be more harmful than sugar that is eaten in foods.“This is the first study to draw clear dose-response relationships between different sugar sources and Type 2 diabetes risk,” said Karen Della Corte, lead author and BYU nutritional science professor, in a news release. “It highlights why drinking your sugar—whether from soda or juice—is more problematic for health than eating it.”Food sugar sources showed no such link and, in some cases, were even associated with a lower risk.The findings, after correcting for body mass index and various lifestyle risk factors, include:Sugary drinks are risky. The risk for developing Type 2 diabetes (T2D) increased by 25% with each additional 12 oz daily serving of sugar-sweetened beverages—including soft drinks, energy drinks, and sports drinks.Fruit juice is also a problem. With each additional 8-oz serving of fruit juice per day—including 100% fruit juice, nectars, and juice drinks—the risk for developing T2D increased by 5%.Individual responses may vary. The above risks are “relative but not absolute,” note the researchers, and depend on a person’s baseline risk of developing T2D; for example, if the average person’s baseline risk of developing T2D is about 10%, four sodas a day could raise that to roughly 20%, not 100%.Sugary food is in a different category. Comparatively, an intake of 20 grams a day (about 1.6 tablespoons) of total sucrose (table sugar) and total sugar (the sum of all naturally occurring and added sugars in the diet) showed an inverse association with T2D, “hinting at a surprising protective association.”Why is drinking sugar worse?It may come down to the differing metabolic effects, explains the news release. “Sugar-sweetened beverages and fruit juice supply isolated sugars, leading to a greater glycemic impact that would overwhelm and disrupt liver metabolism thereby increasing liver fat and insulin resistance,” it notes.But dietary sugars consumed in or added to nutrient-dense foods, such as whole fruits, dairy products, or whole grains, do not cause metabolic overload in the liver. “These embedded sugars,” says the release, “elicit slower blood glucose responses due to accompanying fiber, fats, proteins and other beneficial nutrients.”A note about fruit juiceWhile it might be counterintuitive to think that fruit juice could be in the same relative category of harm as soda, the researchers explain why it makes sense. Compared to sugars from sugar-sweetened beverages (SSBs), which provide empty calories, fruit juice, the study says, “can contain beneficial nutrients such as vitamins and phytochemicals; however, our study found that sugar consumption from fruit juice was positively associated with T2D risk. The high sugar content and lack of fiber in fruit juice are similar to SSBs, making it a poor substitute for whole fruits, which provide higher fiber content to support better blood glucose regulation.”But sugar-sweetened beverages are still worse than sugary foods, as they supply isolated sugars leading to a greater glycemic impact. “Whereas other sources of dietary sugars, particularly when consumed in nutrient-dense foods such as whole fruits, dairy products, or whole grains, may elicit slower blood glucose responses due to accompanying fiber, fats, or proteins,” the researchers note.Finally, they point out that, while future research is still needed to evaluate the long-term impacts of sugar consumption, the findings suggest the importance of sugar type in determining the association of dietary sugar, “with higher liquid sugar intakes apparently linked to greater harm.”More on sugar:Being obsessed with blood sugar might be a mistake for older adults, research showsIt’s time to rethink your relationship with sugar. Here’s howHow much ultraprocessed food is too much? The exact amount that raises your risk of heart disease and cancerThis story was originally featured on Fortune.com