title: Help Me with my SQL Query (Need it to always return at least one row.)
body: <p>First off, here's my SQL query:</p>
  
  <pre><code>SELECT research_cost, tech_name,
      (SELECT research_cost
          FROM technologies
          WHERE research_cost &lt;= USERS_RESEARCH_POINTS_VALUE
          ORDER BY research_cost DESC
          LIMIT 1) as research_prev,
      (SELECT cost
          FROM technology_costs
          WHERE id = 18
          LIMIT 1) as technology_cost
  FROM `technologies`
      JOIN technology_costs
      ON id = COUNT_OF_TECHS_USER_LEARNED
  WHERE research_cost &gt; USERS_RESEARCH_POINTS_VALUE
  ORDER BY research_cost ASC
  LIMIT 1
  </code></pre>
  
  <p>Website link: <a href="http://www.joemajewski.com/fortress/" rel="nofollow noreferrer">http://www.joemajewski.com/fortress/</a></p>
  
  <p>Some people might consider the above query to be moderate-sized, or even small; not me. For me, that's one of the largest and most complex SQL queries I've ever written, so I pushed myself to my limits.</p>
  
  <p>Anyways, the query itself has no syntax errors, and it does exactly what I want it to do, for the most part. There's one minor issue, however.</p>
  
  <p>If the main <code>SELECT</code> clause doesn't return a row (the "SELECT research_cost, tech_name FROM <code>technologies</code> WHERE research_cost > whatever"), then the entire query is an empty set.</p>
  
  <p>If it helps, Fortress is this game that I'm working on. It's a browser-based MMORPG where users build an army to try and get a top stop in the leaderboards. Technologies are a game mechanic where users purchase upgrades to their stats (gold income, unit production, etc). Researching is a game mechanic that allows you to learn new technologies by training scientists to do the researching. That's what this query is all about. It grabs the current technology that is being researched, as well as the research cost of it. It additionally grabs the cost in gold of how much the next technology will cost.</p>
  
  <p>So... is there any way that I can force at least a null row to be returned in the result set, as the nested select statements retrieve variables that I need in the script, even if the outer query returns nothing. Or could someone possibly change it around so that a result is always returned.</p>
  
  <p>If anything else is needed, let me know. :)</p>