Blank value for search in SQL combobox
Last Post 02-02-2012 07:14 PM by Chad Nash. 2 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
marcvanzeeUser is Offline
wading in the water
wading in the water
Posts:24
Avatar

--
02-02-2012 12:11 AM
    I have three fields that are searchable:

    - Name (textfield)
    - Presence (combobox: Yes/No)
    - Room (combobox: Yes/No)

    Now I want to be able to search for Room=Yes with Presence=*, or for Presence=Yes and Room=*.

    I am aware that Dynamic Views currently does not support the OR condition, but I thought I might be able to achieve a similar result by adding a third option to the comboboxes: '---' with the value NULL using the following query:

    Select '---' as SearchOption, NULL as SearchOptionValue
    UNION Select 'Yes' as SearchOption, 'Yes' as SearchOptionValue
    UNION
    Select 'No' as SearchOption, 'No' as SearchOptionValue


    This is because the Dynamic Views documentation states the following:

    "Leaving the search criteria to be „equal‟ or „contains‟ will render results if the field is null or blank; by using this method you can have multiple fields such as zip code, city, and state, and allow the user to search based on only the fields that they enter search terms form"

    Therefore, I thought I simulate making a field blank by sending a NULL value to SQL. This does not seem to work for me, any other work arounds, or thoughts on this subject?

    Thanks,

    Marc.
    marcvanzeeUser is Offline
    wading in the water
    wading in the water
    Posts:24
    Avatar

    --
    02-02-2012 12:17 AM
    I fixed it. It works using the following setup:

    Input type = combobox
    Criteria = contains (equals does NOT work)
    Values = ,Yes,No (the first comma is necessary! it give a NULL value as the first option)

    Chad NashUser is Offline
    Posts:5260
    Avatar

    --
    02-02-2012 07:14 PM
    Hi Marc,

    Yes for any of these that you are trying to use with a blank value, I think you need to use either "CONTAINS" or sometimes "BEGINS WITH" or "ENDS WITH". Basically equals works because sometimes you want it to "Really" mean "EQUALS" such as showing you all results where the results are equal to null/empty etc...

    Thanks for the follow up post and details, this should be helpful to others!

    Thanks,

    Chad


    ---
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi