
Just by looking at it you can see 3 things:
1 - Everything is duplicated
2 - It was copied and pasted.
3 - The field names sux.
Well, guess what, I wrote that code. period.
But now when I look at it, it is disgusting. I'm violating the DRY (Don't repeat yourself) principle and also suffering from the evils of duplication, because I needed to add one field in that select, and if I didn't refactor I would have to add the field 3 times!
But as I'm sucking less now I took some minutes and refactored the code, here is what the code looks like after a quick and little refactoring:

Still not perfect, but way better.