Not equal, multi-select pick column

This topic is: not resolved

This topic contains 8 replies, has 3 voices, and was last updated by  sc0ttkclark 2 years, 5 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #164720

    carlosfaria
    Member

    Hi all,

    I have a recipes pod that is using another pod, ingredients, as a multi-select pick.
    What i want is select the recipes that doesn’t have ‘vinegar’ as one of its ingredients.

    I’m using this code to select data in my pod:

    But it selects all the recipes, the ones with ‘vinegar’ selected an the ones without…

    In fact, when i search for the recipes that have ‘vinegar’ as ingredient, using this code works:

    Any help will be very appreciated.

    #164721

    sc0ttkclark
    Keymaster
    Post count: 803

    Try using != instead of <>

    #164722

    carlosfaria
    Member

    Thanks Scott, but I already tried that and I got the same result. When I query with

    the results are two rows but when I query with:

    the results include that two rows.

    Then, this is the way to do it, right?
    Maybe I should change the name of the column to be different from the table…

    Any other idea?

    The SQL I get is:

    In fact, if I use this SQL code directly in my database with phpMyAdmin, the results are 6 rows with the ones with the ingredient ‘vinegar’ included…

    Hope this is not a bug!! :D

    #164723

    sc0ttkclark
    Keymaster
    Post count: 803

    I noticed "vinegar" is lowercase, is that the way it’s stored in name or are you thinking of the ‘slug’ field?

    #164724

    carlosfaria
    Member

    it’s all lowercase. The name and also the slug…

    #164725

    chris.pilko
    Member

    It’s not a bug: It’s a logic problem akin to the old brain teaser "I’ve got two coins together worth 30 cents in my pocket, and one of them is not a quarter." The answer being that one of them is a nickel, and the other one is a quarter.

    You’ve got a salad dressing with oil and vinegar, therefore one of your ingredients is not vinegar, so the query returns the row.

    You need a WHERE NOT EXISTS subquery to find where none of the ingredients in that recipe is vinegar. I played with it a little, but I’ve run out of time for now. MySQL doc page is here: http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html

    #164726

    carlosfaria
    Member

    Great Chris, I knew something like this was the problem, because phpMyAdmin returns the same as Pods.

    Now my problem is that I’m very bad at such SQL statements, and moreover, to have them working with Pods.

    Should I put that WHERE NOT EXISTS subquery as a parameter in my findRecords call?

    Please, enlight me, Master!!

    #164727

    carlosfaria
    Member

    Still no luck. Anyone can explain me the way to have a WHERE NOT EXISTS subquery as a parameter in my findRecords call?

    I’m a bit frustrated with this…

    #164728

    sc0ttkclark
    Keymaster
    Post count: 803

    Send access to your site to contact@podscms.org and I’ll take a look at it and see if I can fix it for you.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

Wordpress Cloud Hosting