Page 1 of 1

Related records query

PostPosted: Tue Aug 16, 2011 12:49 pm
by barryrs
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

Re: Related records query

PostPosted: Tue Aug 16, 2011 2:35 pm
by ADobkin
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

Re: Related records query

PostPosted: Fri Aug 19, 2011 6:20 am
by barryrs
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

Re: Related records query

PostPosted: Mon Aug 22, 2011 2:00 pm
by shannah
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.