SQL (this AND that), OR (that AND theOther)

Alan Stenhouse alanstenhouse at hotmail.com
Wed Oct 9 04:46:17 EDT 2013


Could you perhaps concatenate the user + car columns to make a new key and then do a select from that?

e.g select * from ( select *, concat(user,car) as myKey from yourTable )

and use an appropriate where clause on that? Though it's not entirely clear what your requirement is.



Alan Stenhouse
alanstenhouse at hotmail.com

Check out our apps on the App Store:

BeatSpeak - the multilingual talking metronome
EV-Point - Find your nearest Electric Vehicle Recharge Station.

On 09/10/2013, at 4:57 AM, use-livecode-request at lists.runrev.com wrote:

> Having some SQL query troubles...  I need to get results from a long list
> in a single query, BUT there are pairs of fields that must match.  Every
> pair is a unique pair, aka no duplicates.  If my list contains 50 pair that
> are unique, I may only get 30 returned rows, but I need all 50.
> This is what I've tried, but SQL strips away my outer parens, making my AND
> less binding for the pair.
>      ((user = 'Joe') AND (car = 'Ford')) OR
>      ((user = 'John') AND (car = 'Chevy')) OR
>      ((user = 'Jim') AND (car = 'Kia')) OR
>      ((user = 'Jim') AND (car = 'Smart'))
> ~Roger

More information about the Use-livecode mailing list