I’m trying to simplify some mysql. I have three selects and three tables:
SELECT pageid FROM thepage WHERE DATE(createdate)='2011-11-09' ORDER BY createdate DESC
SELECT urlid FROM themix WHERE pageid=...
SELECT link FROM theurl WHERE urlid=...
Given a createdate, it gets all pageid’s, then goes to a second table and gets all urlid’s for those pageid’s then gets the links for all those urlid’s. I’m using while loops right now, but suspect there is a way to join them all into one.
Any ideas?
should do the trick i think. If you want only unique URLs, use this:
Sidenotes
will have to scan the whole
pagetable and call theDATE()function for every row. You have two options to make it faster:Change the
createdatetoDATE(fromDATETIMEorTIMESTAMP, that it is now) and use:or keep it as it is and use:
Table and column names are better without prefixes or suffixes like the
theyou have. Isn’t this cleaner and clearer (even without the aliases)?