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.

0 thoughts on “mysql fixes

  1. 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s