[Ur] queryL question

Todd Roth toddjroth at gmail.com
Wed Jul 15 22:04:39 EDT 2015


I’m unable to get a pretty straighforward LEFT JOIN query to work in ur/web and would appreciate any help.  The table setup is as follows:

table user : { Id : int, LastName : string, FirstName : string }
		 PRIMARY KEY Id

table shift : { Id : int, ShortName : string, LongName : string, Hours: int, Created : time , Modified : time}
		  PRIMARY KEY Id

table contract : {Id : int, Shift : int, ShiftDate : time, Seller : int, Buyer : option int, SettledOn : option time, Created : time, Modified : time }
		     PRIMARY KEY Id,
		     CONSTRAINT Shift FOREIGN KEY Shift REFERENCES shift(Id),
		     CONSTRAINT Buyer FOREIGN KEY Buyer REFERENCES user(Id),
		     CONSTRAINT Seller FOREIGN KEY Seller REFERENCES user(Id)

I want the query to return the following columns:

shift.LongName, contract.ShiftDate, user.LastName( for seller), user.LastName(for buyer)

The following psql query works as expected but I can’t figure out the syntax for ur/web.

psql query:  

SELECT ss.uw_longname, c.uw_shiftdate, u1.uw_lastname, u2.uw_lastname FROM uw_shiftxchange_contract AS c
LEFT JOIN uw_shiftxchange_user AS u1 on u1.uw_id = c.uw_seller 
LEFT JOIN uw_shiftxchange_user AS u2 on u2.uw_id = c.uw_buyer 
LEFT JOIN uw_shiftxchange_shift AS ss on c.uw_shift = ss.uw_id


More information about the Ur mailing list