So have you read the Wix Support pages about using reference fields and multiple datasets?
https://support.wix.com/en/article/adding-a-reference-field-to-a-database-collection
https://support.wix.com/en/article/about-reference-fields-in-database-collections
https://support.wix.com/en/article/about-connecting-multiple-database-collections
https://support.wix.com/en/article/displaying-content-from-multiple-database-collections-using-datasets
https://support.wix.com/en/article/about-displaying-content-from-multiple-database-collections-using-datasets
https://support.wix.com/en/article/displaying-content-from-multiple-database-collections-using-reference-fields-4034931
Always much easier to do it through the datasets and their settings if you can, saves having the hassle of working out and writing out the code in the first place.