Related records query

Archived from the Xataface Users forum.

barryrs — Tue Aug 16, 2011 12:49 pm

Steve,

Thanks again for a great product! I really enjoy seeing a db front end come together so easily!!
Thought you might enjoy this

Had trouble pulling related records with additional criteria (ie. relationships cannot use OR, etc.)
My solution? Tell it what I don’t want, it’ll give me the rest
(All I wanted was types 3 or 4)

__sql__ = “SELECT * FROM transaction WHERE AccountID= ‘$AccountID’ and TransactionTypeID != 1 and TransactionTypeID != 2 and TransactionTypeID != 5 and TransactionTypeID != 6 and TransactionTypeID != 7”

Thanks again,
-Barry


ADobkin — Tue Aug 16, 2011 2:35 pm

I wasn’t aware of the ‘OR’ restriction in relationships.ini, but would this work?

__sql__ = “SELECT * FROM transaction WHERE AccountID= ‘$AccountID’ AND (TransactionTypeID = 3 OR TransactionTypeID = 4)”

Just a bit shorter and more to the point, but your solution is a good workaround if ‘OR’ is completely unsupported.

Alan


barryrs — Fri Aug 19, 2011 6:20 am

That was my original code! But alas, it didn’t work, that’s how I eventually discovered the restriction (in the wiki).
Steve mentioned (wrote) he may revisit a solution to the ‘OR’ issue at some later date.

Cheers, Baer


shannah — Mon Aug 22, 2011 2:00 pm

In either of these cases I think it will give the parser problems at some point. The OR restriction on relationships is because if there is an OR clause then Xataface doesn’t know exactly how to insert new records into the relationship. Same thing happens with a != comparison.