Jump to content

rivan

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Posts posted by rivan

  1. Did you try regexp like variant?

     

    select * from mapcontent where lower(content) rlike '[[:<:]]tea[[:>:]]'

     

    (I am not expert in mysql so I am not sure how its regexp support works, this is just a hint  :) )

  2. You can do something like this (I usually solved similar problems that way) - SQL first

    select t1.MainID, t1.Company, t2.SubID, t2.SubCompany from table1 t1 join table2 t2 on t1.MainID = t2.MainID order by t1.MainID
    

    then in php something like

    $last_company_id = -1;
    while (some_data_read()) {
          if ($last_company_id != $current_company_id) {
                if ($last_company_id != -1)
                      echo "</item">; // to close that tag of previous main category
                $last_company_id = $current_company_id;
                echo "<item id='parent' value='$current_company'>"; // openning tag for new category
          }
          echo "<item id='child' value='$current_subcompany'/>";
    }
    
    // now just finish last open main company if any
    if ($last_company_id != -1)
          echo "</item">;
    

     

    I think you got the idea - remember main company you are working with currently, when it changes then create the new tag and do whatever necessary

  3. First you can't nest form elements (it sounds to me like you are nesting them) - use only one form tag with both enctype and action - after posting that form _FILES array normaly would be filled with names of temporary files created (it is superglobal variable, so PHP would take care of setting it right), after working with those temporary files you should erase them

    (I believe the only problem you have is with this form tag in html)

  4. Well, I didn't understand that he needs unique IDs across runs - if that is the case then it is better to have unique column with sequence in every table and then to concatenate only that columns (I think that wouldn't look so ugly)

    Anyway it sounds pretty meaningless to have persistent non-existent-in-database id of the row - what for you can use it if you are not storing it somewhere?

  5. What you should do, is to create some script to

    1. read data from db to memory (since it is not that huge number of records)

    2. calculate similarity between entries (that is called minimal edit distance, you can find algorithms at http://en.wikipedia.org/wiki/Edit_distance) - better to use some heuristics when calculating this (for example only for strings that begin with same later, if starting with different letters you can say that edit distance is some big number like 99) - this can take considerable time

    3. dump results in some text file with edit distance as first column

    4. sort that file using sort command if you are using some unix

    5. look from beginning of the file since edit distance will be sorted in increasing order

     

    Hope that will help

  6. You should use sequence to solve this (like somebody mentioned) - here is example

    create sequence blahahaha; -- sequence creation - do this only once

     

    then always append this nextval part to your query (to generate column with unique values)

     

    select nextval('blahahaha') as unique_column, * from some_table

     

    Regards

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.