Professional Web Applications Themes

Database search - Coldfusion - Advanced Techniques

Hi, This may be a stupid question but i cannot seem to work it out. i am creating a site for a law directory which is searchable through the database. Each company could have 10 areas of law. Some have 2 others have 10. The way i have created the database is the all the areas of law are in one field called area of law like this crime,employment,immigration. I am having problems when it comes to the search as i want to be able to search by area of law but it only for one at a time. I ...

  1. #1

    Default Database search

    Hi,

    This may be a stupid question but i cannot seem to work it out.

    i am creating a site for a law directory which is searchable through the
    database. Each company could have 10 areas of law. Some have 2 others have
    10. The way i have created the database is the all the areas of law are in one
    field called area of law like this crime,employment,immigration. I am having
    problems when it comes to the search as i want to be able to search by area of
    law but it only for one at a time. I keep getting that it cannot find that
    area. is there a code that i can use to spit up the columns when called or
    will i need to redesign the database. If so what do you think is my best option

    Thanks

    cybertek23 Guest

  2. #2

    Default Re: Database search

    I think your best option is to normalize your database.
    Dan Guest

  3. #3

    Default Re: Database search

    Could you please explain what you mean
    cybertek23 Guest

  4. #4

    Default Re: Database search

    What Dan means is that you need a seperate table that contains all your law
    areas and another table that creates a join between companies and their law
    areas. This is the basis of relational databases, it is a fundamental techique
    for building web apps. I would suggest buying a good SQL book and reading it
    and it will become abundently clear.

    Stressed_Simon Guest

  5. #5

    Default Re: Database search

    This should get you started
    http://en.wikipedia.org/wiki/Database_normalization
    Dan Guest

  6. #6

    Default Re: Database search

    As they've both said, normalising the database is definitely the way to go.

    However, if you need a quick & dirty solution to get things working, you can
    possibly use:
    WHERE area_of_law LIKE '%#search_term#%'
    the key parts there being LIKE instead of = and the %s at start and end.
    Worth noting it will return irrelevant results if any areas are contained
    inside others (ie: if there was a "rat" area, it would also incorrectly match
    "immigRATion")

    boughtonp Guest

Similar Threads

  1. Database Search
    By ReaperTK in forum Macromedia ColdFusion
    Replies: 3
    Last Post: April 25th, 07:04 PM
  2. search the database
    By Kamesh192 in forum Macromedia ColdFusion
    Replies: 0
    Last Post: April 18th, 02:59 PM
  3. Web search in SQL database
    By Stefano B* in forum ASP.NET Web Services
    Replies: 0
    Last Post: October 5th, 01:33 PM
  4. database search in CD
    By carlos.carvalhar in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 19th, 06:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139