sql statement wildcard in fieldname

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Hardy

    sql statement wildcard in fieldname

    I am trying to search for a field where the wildcard needs to be in
    the field name i.e.:

    select * from userlist where fun??? = true order by lasNam, firNam

    However, Access won't let me do this. Can anyone help show me how to
    do this?

    Thanks.
  • Matthew Sullivan

    #2
    Re: sql statement wildcard in fieldname

    I don't think that's doable, but I can't say for sure it's not.
    (Someone else will have to jump in to say for sure.)

    How many "fun*" fields are there? If there are not too many, you
    could use a WHERE clause like:
    WHERE [funA = true] OR [funB = true]

    -Matt


    On 8 Dec 2003 23:11:09 -0800, danhardy@myreal box.com (Dan Hardy)
    wrote:
    [color=blue]
    >I am trying to search for a field where the wildcard needs to be in
    >the field name i.e.:
    >
    >select * from userlist where fun??? = true order by lasNam, firNam
    >
    >However, Access won't let me do this. Can anyone help show me how to
    >do this?
    >
    >Thanks.[/color]

    Comment

    • Van T. Dinh

      #3
      Re: sql statement wildcard in fieldname

      Dou you meant you have, for example, 3 Field named:

      fun001
      fun002
      fun003

      and you want the Query to select the Record if

      [fun001] = True And/Or
      [fun002] = True And/Or
      [fun003] = True
      ?

      In this case, it is NOT possible. You can see that I don't even know
      whether you meant AND or OR. Perhaps, you should set up the Query like:

      WHERE [fun001] = True
      OR [fun002] = True
      OR [fun003] = True

      I would also suggest you check out your Table Structure against the
      Relational Database Design Principles. One of the principles / rules /
      normal forms is that you should not have repeating groups and the way you
      named the Fields and selected Records in the Query seem to indicate that you
      have repeating groups (of 1 Field in each group) in your Table.

      --
      HTH
      Van T. Dinh




      "Dan Hardy" <danhardy@myrea lbox.com> wrote in message
      news:bfbec751.0 312082311.54ea5 f34@posting.goo gle.com...[color=blue]
      > I am trying to search for a field where the wildcard needs to be in
      > the field name i.e.:
      >
      > select * from userlist where fun??? = true order by lasNam, firNam
      >
      > However, Access won't let me do this. Can anyone help show me how to
      > do this?
      >
      > Thanks.[/color]


      Comment

      • Dan Hardy

        #4
        Re: sql statement wildcard in fieldname

        Van,

        Thanks for your help. You're right that I screwed up in the
        normalization, but the database is not big enough for me to really
        worry about it.

        Basically, what I want it
        IF fun001 = TRUE THEN
        do this

        ELSE IF fun002 = TRUE
        do this
        etc.

        It's for an asp website. Any more thoughts? Otherwise it won't be
        too much trouble for me just to do the above.

        Thanks.

        Dan Hardy

        "Van T. Dinh" <VanThien.Dinh@ PlseUseNewsGrou p.bigpond.com> wrote in message news:<OgiBb.459 26$aT.9177@news-server.bigpond. net.au>...[color=blue]
        > Dou you meant you have, for example, 3 Field named:
        >
        > fun001
        > fun002
        > fun003
        >
        > and you want the Query to select the Record if
        >
        > [fun001] = True And/Or
        > [fun002] = True And/Or
        > [fun003] = True
        > ?
        >
        > In this case, it is NOT possible. You can see that I don't even know
        > whether you meant AND or OR. Perhaps, you should set up the Query like:
        >
        > WHERE [fun001] = True
        > OR [fun002] = True
        > OR [fun003] = True
        >
        > I would also suggest you check out your Table Structure against the
        > Relational Database Design Principles. One of the principles / rules /
        > normal forms is that you should not have repeating groups and the way you
        > named the Fields and selected Records in the Query seem to indicate that you
        > have repeating groups (of 1 Field in each group) in your Table.
        >
        > --
        > HTH
        > Van T. Dinh
        >
        >
        >
        >
        > "Dan Hardy" <danhardy@myrea lbox.com> wrote in message
        > news:bfbec751.0 312082311.54ea5 f34@posting.goo gle.com...[color=green]
        > > I am trying to search for a field where the wildcard needs to be in
        > > the field name i.e.:
        > >
        > > select * from userlist where fun??? = true order by lasNam, firNam
        > >
        > > However, Access won't let me do this. Can anyone help show me how to
        > > do this?
        > >
        > > Thanks.[/color][/color]

        Comment

        • Van T. Dinh

          #5
          Re: sql statement wildcard in fieldname

          I am not sure about "do this" and "do that" in a Query. Queries normally
          returns (sets of) values, not actions.

          If you want to return values, perhaps you can create a UDF (User-Defined
          Function) and use this UDF to return the value you want. Something like:

          ****Pseudo code only****
          Public Function fnReturnValue _
          ( ByVal fFun001 As Boolean, _
          ByVal fFun002 As Boolean, _
          ... ) As
          RequiredReturnT ype

          If fFun001 = True Then
          fnReturnValue = ...
          ElseIf = True Then
          fnReturnValue = ...
          ...
          Else

          End If

          End Function
          ********

          --
          HTH
          Van T. Dinh
          MVP (Access)



          "Dan Hardy" <danhardy@myrea lbox.com> wrote in message
          news:bfbec751.0 312100851.10314 8ef@posting.goo gle.com...[color=blue]
          > Van,
          >
          > Thanks for your help. You're right that I screwed up in the
          > normalization, but the database is not big enough for me to really
          > worry about it.
          >
          > Basically, what I want it
          > IF fun001 = TRUE THEN
          > do this
          >
          > ELSE IF fun002 = TRUE
          > do this
          > etc.
          >
          > It's for an asp website. Any more thoughts? Otherwise it won't be
          > too much trouble for me just to do the above.
          >
          > Thanks.
          >
          > Dan Hardy
          >[/color]



          Comment

          • Van T. Dinh

            #6
            Re: sql statement wildcard in fieldname

            Sorry, I missed the part about "asp web site". My answer is for an Access
            application.

            Since you use the database / MDB file to store data only (hence you are
            using a JET database, NOT really an Access database), I am not sure how you
            can implement the equivalent of the UDF in ASP.

            --
            HTH
            Van T. Dinh
            MVP (Access)



            "Dan Hardy" <danhardy@myrea lbox.com> wrote in message
            news:bfbec751.0 312100851.10314 8ef@posting.goo gle.com...


            Comment

            Working...