SQL statement For a recordset

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default SQL statement For a recordset

    I have 2 tables tbMembers and tbMembersAccessLvl

    I know that a person may have more that one accesslevel in the
    tbMemberAccessLvl, I only want to retrieve the highest number (the access
    level can only be 0,1,2).
    The statement below is retrieveing the lowest one because its the first one
    it comes across.

    SELECT tbMembers.MemberId, tbMembers.MemberPass, tbMembers.email,
    tbMemberAccessLvl.AccessLvl
    FROM tbMembers CROSS JOIN tbMemberAccessLvl
    WHERE (tbMembers.MemberId = '402195') AND (tbMembers.MemberPass =
    'ebony')

    How can i get the record that supports the above statement but also gets the
    highest tbMemberAccessLvl.AccessLvl.

    There might be 3 records that have MemberId = '402195' and MemberPass =
    'ebony' but i want the one with the highest value in
    tbMemberAccessLvl.AccessLvl. Do i need to use the MAX prefix??

    I tried SELECT tbMembers.MemberId, tbMembers.MemberPass,
    tbMembers.email, MAX(tbMemberAccessLvl.AccessLvl) but the server said I need
    a "Group by" not sure how any ideas.

    This select statement is what I will change the recordest in DWMX2004 to be
    instead of the normal recordset from one table. Please help


    Tim Mannah Guest

  2. Similar Questions and Discussions

    1. Need help with a recordset
      I need some help with a recordset that selects a series of items with options. The problem is when I select the item it shows a list of options....
    2. RECORDSET
      I am trying to make a data base for a ASP website. But when I try to write the code DataSet11.Recordset.Addnew. Appears error when I compile to...
    3. ASP Recordset Help!
      Hi, I have been trying to construct a results page in dreamweaver/asp if i put a search in with one parameter it works fine (ie, select name from...
    4. Is this possible with a recordset?
      Hello, Looking for some expert help. I am using Dreamweaver MX 2004. I have a need that I was wondering if it was possible accomplish using a...
    5. RecordSet.Move or RecordSet.AbsolutePosition??
      Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to...
  3. #2

    Default Re: SQL statement For a recordset

    Tim

    Would the below work:

    SELECT Top 1 tbMembers.MemberId, tbMembers.MemberPass, tbMembers.email,
    tbMemberAccessLvl.AccessLvl
    FROM tbMembers CROSS JOIN tbMemberAccessLvl
    WHERE (tbMembers.MemberId = '402195') AND (tbMembers.MemberPass =
    'ebony')
    ORDER BY tbMemberAccessLvl.AccessLvl DESC

    Brendan


    "Tim Mannah" <timm@diabetesnsw.com.au> wrote in message
    news:d0qlc8$gjr$2@forums.macromedia.com...
    > I have 2 tables tbMembers and tbMembersAccessLvl
    >
    > I know that a person may have more that one accesslevel in the
    > tbMemberAccessLvl, I only want to retrieve the highest number (the access
    > level can only be 0,1,2).
    > The statement below is retrieveing the lowest one because its the first
    one
    > it comes across.
    >
    > SELECT tbMembers.MemberId, tbMembers.MemberPass, tbMembers.email,
    > tbMemberAccessLvl.AccessLvl
    > FROM tbMembers CROSS JOIN tbMemberAccessLvl
    > WHERE (tbMembers.MemberId = '402195') AND (tbMembers.MemberPass =
    > 'ebony')
    >
    > How can i get the record that supports the above statement but also gets
    the
    > highest tbMemberAccessLvl.AccessLvl.
    >
    > There might be 3 records that have MemberId = '402195' and MemberPass =
    > 'ebony' but i want the one with the highest value in
    > tbMemberAccessLvl.AccessLvl. Do i need to use the MAX prefix??
    >
    > I tried SELECT tbMembers.MemberId, tbMembers.MemberPass,
    > tbMembers.email, MAX(tbMemberAccessLvl.AccessLvl) but the server said I
    need
    > a "Group by" not sure how any ideas.
    >
    > This select statement is what I will change the recordest in DWMX2004 to
    be
    > instead of the normal recordset from one table. Please help
    >
    >

    Singularity.co.uk Guest

  4. #3

    Default Re: SQL statement For a recordset

    This just orders them but doesnt issolated the specific access level the MAX
    ended up working when i added a group by clause that groups by all fields
    except the one being MAX'ed

    "Tim Mannah" <timm@diabetesnsw.com.au> wrote in message
    news:d0qlc8$gjr$2@forums.macromedia.com...
    > I have 2 tables tbMembers and tbMembersAccessLvl
    >
    > I know that a person may have more that one accesslevel in the
    > tbMemberAccessLvl, I only want to retrieve the highest number (the access
    > level can only be 0,1,2).
    > The statement below is retrieveing the lowest one because its the first
    one
    > it comes across.
    >
    > SELECT tbMembers.MemberId, tbMembers.MemberPass, tbMembers.email,
    > tbMemberAccessLvl.AccessLvl
    > FROM tbMembers CROSS JOIN tbMemberAccessLvl
    > WHERE (tbMembers.MemberId = '402195') AND (tbMembers.MemberPass =
    > 'ebony')
    >
    > How can i get the record that supports the above statement but also gets
    the
    > highest tbMemberAccessLvl.AccessLvl.
    >
    > There might be 3 records that have MemberId = '402195' and MemberPass =
    > 'ebony' but i want the one with the highest value in
    > tbMemberAccessLvl.AccessLvl. Do i need to use the MAX prefix??
    >
    > I tried SELECT tbMembers.MemberId, tbMembers.MemberPass,
    > tbMembers.email, MAX(tbMemberAccessLvl.AccessLvl) but the server said I
    need
    > a "Group by" not sure how any ideas.
    >
    > This select statement is what I will change the recordest in DWMX2004 to
    be
    > instead of the normal recordset from one table. Please help
    >
    >

    Tim Mannah 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