No announcement yet.

Checkbox- Automatic Lookup

  • Filter
  • Time
  • Show
Clear All
new posts

  • Checkbox- Automatic Lookup

    Good evening all,

    I am very new to SC and I must say it is a great application! I am creating an application that utilizes the automatic lookup for the checkbox control. For me the UI development is not a question but rather how can I best extract the data from the data table; what would the query look like?

    If the data is stored in a single row with a semicolon as the delimiter, how would I separate out each entry? (Table Example

    ID Course Department
    1 | Course 1 | Dpt1; Dpt2; Dpt3
    2 | Course 2 | Dpt3; Dpt4; Dpt5

    I guess this is more of an MySQL question.

    An example would really help me here!

    Thanks for your consideration of my question..


  • #2
    MySql does not provide a function to split a delimited string. You would have to create your own one. It's not that difficult but not very flexible. I would suggest to have a look at the explode()-function in php, which is pretty straight forward.



    • #3
      Try using SUBSTRING_INDEX(str,delim,count)


      Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.

      mysql> SELECT SUBSTRING_INDEX('', '.', 2);
      -> 'www.mysql'
      mysql> SELECT SUBSTRING_INDEX('', '.', -2);
      -> ''

      This function is multi-byte safe.