need help on DISTINCT

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

  1. #1

    Default need help on DISTINCT

    Hi ALl,

    I need some help on DISTINCT in a query I'm trying to run.
    I have two tables which are linked. This is the query I use:

    SQL = "SELECT DISTINCT name, category, land, task, nbc_protect,
    airportable, amphebian, alternative, capacity_fuel, crew, height,
    length, width, range_max, range_eff, range_cruise, speed_road,
    terrain_water, speed_terrain, calibre, rate_of_fire, weight,
    penetration, type_ammo, diameter, radius_casualty, type_fuse,
    type_grenade, traverse, num_rotor_blades, num_barrels, altitude_max,
    pressure, charge, max_speed_air, ceiling, datum_invoer,
    datum_controle, time_controle, weaponkey, ImagePathAndFile " & _
    "FROM Weapon INNER JOIN Images ON Weapon.WID = Images.IID"
    Order = "name"

    The Table Weapon has a autonumber (WID) which is linked to the IID in
    Images.
    There are several recs in Weapon which have more then one picture
    linked to it.
    The way it is now I see these records several times in the query
    results.

    I want them to show up only once. What do I have to alter here?

    Regards
    Marco
    Krechting Guest

  2. Similar Questions and Discussions

    1. SUM (DISTINCT) INNER JOIN
      I have two tables recording the sales transactions with purchase_id the common key Table 1 (Recording total amounts and customer info) ...
    2. SQL Distinct
      I want to select distinct value from one field of the table and select rest of the corresponding fields accordingly. I have a table that has fields:...
    3. Using DISTINCT for some but not others in 1 query
      I feel really stupid. That doesn't happen too often.. but I feel really stupid. SQL is completely kicking my face in right now. So to get...
    4. SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
      Following is my stored procedure. If I take the DISTINCT out then everything works fine. BUT I need the distinct because it returns duplicate...
    5. SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items mustappear in the select list if SELECT DISTINCT is specified.
      Dan, You should be able to do this: SELECT Id, FaxID, ReceivedTime, Pages FROM ( SELECT DISTINCT .Id AS Id,
  3. #2

    Default Re: need help on DISTINCT

    So, what do you want, any arbitrary image from the Images table?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Krechting" <m.krechting@chello.nl> wrote in message
    news:a71c776d.0401111322.36869a13@posting.google.c om...
    > Hi ALl,
    >
    > I need some help on DISTINCT in a query I'm trying to run.
    > I have two tables which are linked. This is the query I use:
    >
    > SQL = "SELECT DISTINCT name, category, land, task, nbc_protect,
    > airportable, amphebian, alternative, capacity_fuel, crew, height,
    > length, width, range_max, range_eff, range_cruise, speed_road,
    > terrain_water, speed_terrain, calibre, rate_of_fire, weight,
    > penetration, type_ammo, diameter, radius_casualty, type_fuse,
    > type_grenade, traverse, num_rotor_blades, num_barrels, altitude_max,
    > pressure, charge, max_speed_air, ceiling, datum_invoer,
    > datum_controle, time_controle, weaponkey, ImagePathAndFile " & _
    > "FROM Weapon INNER JOIN Images ON Weapon.WID = Images.IID"
    > Order = "name"
    >
    > The Table Weapon has a autonumber (WID) which is linked to the IID in
    > Images.
    > There are several recs in Weapon which have more then one picture
    > linked to it.
    > The way it is now I see these records several times in the query
    > results.
    >
    > I want them to show up only once. What do I have to alter here?
    >
    > Regards
    > Marco

    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