Innanzitutto dovresti postare l'errore, la query e le tabelle.