I have a record that has two people records associated with it. The people records are sellers (peoplecode = 20)and clients (peoplecode = 1). I want the city of both the seller and the client. I thought it would be straight forward, but cannot seem to get it to work - I get no results. The Folderpeople table just relates my folder to my people.
select f.folderid, f.foldername, fp.peoplecode,
p.addrcity as clientcity, p2.addrcity as sellercity
from folder f
join folderpeople fp on fp.folderid = f.folderid
join people p on fp.peopleid = p.peopleid and fp.peoplecode = 1
join people p2 on fp.peopleid = p2.peopleid and fp.peoplecode = 20 ;