mysql fixes

I had a query something like this returning many duplicate rows:

SELECT entries.permalink, video.id, … FROM entries, entries2video, video WHERE entries.feedid = ‘1′ AND entries.id = entries2video.entryid AND video.id = entries2video.videoid ORDER BY id DESC LIMIT

It turns out the fix was pretty easy: instead of “order by id”, make it “order by entries.id” (which makes more sense). I am not sure why, but this fixed the problem of returning duplicate rows.

One Response to “mysql fixes”

  1. James Spahr Says:

    Wow, MySQL didn’t choke on the ORDER BY id ? probably because (maybe?) of selecting video.id, it was the only id being selected, so it used that for ordering?

Leave a Reply