You can join tables from two different schemas by using the syntax "JOIN <SCHEMA>.<TABLE>" to refer to the table in another schema.
For example, suppose you have the following tables, one in the study schema, the other in the lists schema:
study.Demographics
ParticipantId | Language | Gender |
---|
PT-101 | English | M |
PT-102 | French | F |
PT-103 | German | F |
lists.Languages
LanguageName | TranslatorName | TranslatorPhone |
---|
English | Monica Payson | (206) 234-4321 |
French | Etiene Anson | 206 898-4444 |
German | Gundula Prokst | (444) 333-5555 |
The following SQL JOIN creates a table that combines the data from both source tables.
SELECT Demographics.ParticipantId,
Demographics.Language,
Languages.TranslatorName,
Languages.TranslatorPhone,
Demographics.Gender
FROM Demographics
JOIN lists.Languages ON Demographics.Language=Languages.LanguageName
The data returned:
ParticipantId | Language | TranslatorName | TranslatorPhone | Gender |
---|
PT-101 | English | Monica Payson | (206) 234-4321 | M |
PT-102 | French | Etiene Anson | 206 898-4444 | F |
PT-103 | German | Gundula Prokst | (444) 333-5555 | F |