Select IF...

22 Aug 2006
Posted by joshb

So today's brain teaser, how to best select either column A or column B in MySQL. Here's the setup. We have three columns that count. They are:

  • Name
  • Grade
  • Alt. Grade

In most rows there is a grade and no alt. grade. But every once in a while there are both a grade and an alt. grade. If it were an either-or case it would be simple. But it's an either-and. The question of the day is how to best accomplish it in MySQL 5.

Tags:

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Link to Amazon products with: [amazon product_id inline|full|thumbnail]. Example: [amazon 1590597559 thumbnail]
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You may insert videos with [video:URL]
  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
  • Allowed HTML tags: <a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul><p> <img> <table> <tr> <td><strong><em><sup><div><fn><h1><h2><h3><h4><blockquote><img style="">
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically. (Better URL filter.)

More information about formatting options

 
 
 

Live from twitter...

  • Funny how much relief knowing that I have a meeting setup with a good attorney to handle specious claims is. 11 hours 50 min ago
  • @tacanderson Downtown Star! :) 17 hours 3 min ago
  • @seansaxon now what did Nebraska do to deserve that? 17 hours 3 min ago
  • @tacanderson you know as somebody with a 25-commute I had forgotten how much I'm not missing the window scrapers... 19 hours 10 min ago