SHARE
TWEET

Untitled

a guest Jan 19th, 2019 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. id    aName  code
  2. ------------------
  3. 1     dog     DG  
  4. 2     cat     CT  
  5. 3     bat     BT  
  6. 4     badger  BDGR
  7. ...   ...     ...
  8.    
  9. id   orgID   isTranslated  langID   aName    
  10. ----------------------------------------------
  11. 1     2           1         3       katze    
  12. 2     1           1         3       hund      
  13. 3     3           0         3       (NULL)    
  14. 4     4           1         3       dachs    
  15. ...   ...         ...       ...     ...
  16.    
  17. id Langcode
  18. -----------
  19. 1    FR  
  20. 2    CZ
  21. 3    DE
  22. 4    RU
  23. ...  ...
  24.    
  25. id    aName  code    isTranslated
  26. ---------------------------------  
  27. 1     hund     DG         1
  28. 2     katze    CT         1
  29. 3     bat      BT         0
  30. 4     dachs    BDGR       1
  31. ...   ...      ...        ...
  32.    
  33. SELECT Original.id,
  34.        CASE isTranslated
  35.          WHEN 1 THEN Translated.aName
  36.          ELSE        Original.aName
  37.        END AS aName,
  38.        code,
  39.        isTranslated
  40. FROM Original
  41. JOIN Translated ON Original.id = Translated.orgID
  42. WHERE Translated.langID = (SELECT id FROM Lang WHERE Langcode = 'DE')
  43.    
  44. SELECT Original.id, Original.code, Translated.aName
  45. FROM Original
  46. JOIN Lang
  47. ON Lang.langCode = 'DE'
  48. JOIN Translated
  49. ON Translated.orgId = Original.id
  50. AND Translated.langId = Lang.id
  51. AND Translated.aName IS NOT NULL;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top