Need help with improving my databasequery.

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Need help with improving my databasequery.

    I have the following MS Access table:
    Name -- Content
    Attributes -- Title
    Shortdesc
    Longdesc
    Synoniemen

    Using the next query I retrieve records from the table.
    SELECT Content.Title, Content.ShortDesc, Content.Longdesc,
    Content.synoniemen FROM Content WHERE ((Content.synoniemen LIKE
    '%Blah%') OR (Content.Title LIKE '%Blah%') OR (Content.ShortDesc LIKE
    '%Blah%') OR (Content.longdesc LIKE '%Blah%')) ORDER BY Title;

    This query gives me all the records I need but I like to present them
    in a specific order.
    If the searchword is found in the TITLE field it is more important
    then when it is found in the SYNONIEMEN field. The SYNONIEMEN field is
    more important than the SHORTDESC field etc.

    Is there a way to present the results in the desired order
    (Title-Synoniemen-Shortdesc-Longdesc) ?

    Thanx in advance.
    Tallman
    Tallman Guest

  2. Similar Questions and Discussions

    1. Improving frame rate
      Hi. I have a scene with 20 animated and textured models, at about 1000 polygons each, and I?m getting REAL slow frame rates. Most of the time it...
    2. Need help improving authorization
      I don't have a response in framework.aspnet, may be this one is a more appropriate group. = = = = = = = = = = = = = = = = == = = = = = == = = =...
    3. improving page tool
      it would be great if it is possible to drag and drop pages between open FH documents with page tool, great for building layouts. also a´book´...
    4. Improving embedded browser
      Dear sirs, I want to embed a browser inside my Director's movie. I have succeeded in embedding IE Active X control, but although it prefectly...
    5. ? improving on a Sony707
      I am reposting this as it seems to have got a bit lost. I am at present using aSony F707 and getting some good pics but a one off chance to...
  3. #2

    Default Re: Need help with improving my databasequery.

    Could you do a UNION?


    SELECT Title, ShortDesc, LongDesc, Synoniemen, [rank] = 1
    FROM Content
    WHERE Title LIKE '%BLAH%'
    UNION
    SELECT Title, ShortDesc, LongDesc, Synoniemen, [rank] = 2
    FROM Content
    WHERE Synoniemen LIKE '%BLAH%'
    UNION
    SELECT Title, ShortDesc, LongDesc, Synoniemen, [rank] = 3
    FROM Content
    WHERE ShortDesc LIKE '%BLAH%'
    UNION
    SELECT Title, ShortDesc, LongDesc, Synoniemen, [rank] = 4
    FROM Content
    WHERE LongDesc LIKE '%BLAH%'
    ORDER BY rank, title


    In SQL Server, you could use a CASE expression in the ORDER BY clause...





    "Tallman" <tallman@tlzone.zzn.com> wrote in message
    news:3b606e0a.0310150432.6017d977@posting.google.c om...
    > I have the following MS Access table:
    > Name -- Content
    > Attributes -- Title
    > Shortdesc
    > Longdesc
    > Synoniemen
    >
    > Using the next query I retrieve records from the table.
    > SELECT Content.Title, Content.ShortDesc, Content.Longdesc,
    > Content.synoniemen FROM Content WHERE ((Content.synoniemen LIKE
    > '%Blah%') OR (Content.Title LIKE '%Blah%') OR (Content.ShortDesc LIKE
    > '%Blah%') OR (Content.longdesc LIKE '%Blah%')) ORDER BY Title;
    >
    > This query gives me all the records I need but I like to present them
    > in a specific order.
    > If the searchword is found in the TITLE field it is more important
    > then when it is found in the SYNONIEMEN field. The SYNONIEMEN field is
    > more important than the SHORTDESC field etc.
    >
    > Is there a way to present the results in the desired order
    > (Title-Synoniemen-Shortdesc-Longdesc) ?
    >
    > Thanx in advance.
    > Tallman

    Aaron Bertrand - MVP Guest

Posting Permissions

  • You may not post new threads
  • You may 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