Question: who killed joffrey in the books?
Answer: Olenna Tyrell later confides to Margaery that it was she who poisoned Joffrey in order to protect her from Joffrey's beastly nature that he had very clearly displayed with Sansa, and Petyr Baelish reveals to Sansa that he and Dontos Hollard provided Olenna with the poison.