Created
          October 29, 2013 15:04 
        
      - 
      
- 
        Save thomsbg/7216377 to your computer and use it in GitHub Desktop. 
    Left outer join + if statement
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | select stuff.*, if( | |
| exchange_rate.rate is null, | |
| (select rate from exchange_rates order by month desc limit 1), | |
| exchange_rate.rate | |
| ) | |
| from stuff | |
| left outer join exchange_rate on exchange_rate.stuff_id = stuff.id; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment