journal
all all entries rss SoML excited dreams runes YRUU ultimate KTRU skate sleepy nihongo
Rob is 20,117 days old today.
prev day next day printable version

Entries this day: phpMyAdmin

phpMyAdmin

9:24pm JST Tuesday 11 December 2007 (day 13775)

Note to self:

Self, if you need to write a hairy mySQL query, and you have a choice between

  • editing, saving, running code
  • using phpMyAdmin

use phpMyAdmin.

What I couldn't do all day (I'm talkin' 8 hours) via the first method, I did in 1 hour the second way. Here is the resulting mySQL:

SELECT um.uid, mi.mission_type, up.mission_id, up.publish_id, ur.status
FROM User_Remun AS ur
RIGHT JOIN User_Publish AS up
USING ( publish_id )
LEFT JOIN Mission_Info AS mi
USING ( mission_id )
LEFT JOIN User_Master AS um
USING ( uid )
WHERE uid =4
AND mi.start_term <= now( ) AND mi.end_term >= now( )
AND ((mi.mission_type = 'normal' AND ur.status IS NULL)
     OR (mi.mission_type = 'monitor' AND ur.status = 9))
{AND mi.mission_id = 46}

The last line is optional, depending on whether the user said "tell me what I can do" or asked "can I do this?"

All in one beautiful query, that merges four (4) tables and runs in about 0.0006 seconds...

permalink
prev day next day