title: MySQL: Getting a row from another table that has a column value over the current one
body: <p>Apologies for the weird title phrasing, but I honestly don't know how to explain this any better. The query in itself with the context might be clearer, though:</p>
  <pre><code>UPDATE logentry 
  JOIN logtier ON logentry.logtierid = logtier.idlogtier 
  SET logentry.logtierid = NEW.idlogtier 
  WHERE logentry.logid = NEW.logid 
  AND logentry.valuelogentry BETWEEN NEW.thresholdlogtier AND 1000
  </code></pre>
  <p>I have log entries that have tiers depending on their value. So for instance, a log entry could have a value of 50 and have Tier 1 which is for values over 25. I could have Tier 2 which is 100, so as long as a value is between 50 and 100, it'll be Tier 1... You get the idea.<br />
  So basically, the idea here is that I have a trigger that's being run when a new tier is being inserted. As you can see in the query above, I want to update the existing log entries with the new tier that's being added. I have no issues updating all the entries whose values are over the newly added tier's threshold, however, I do not know how to prevent entries that are above the next existing tier from being updated (because they're not included in the [new tier; next tier] interval). The &quot;1000&quot; that I wrote in the query is what should be the value of the next tier, and I just don't know how to retrieve that.<br />
  Thanks for the help and sorry for the messy explanation!</p>