Results 1 to 2 of 2
  1. #1
    rojo527 is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    1

    Refering to a query field within the same query

    In Access you can refer to a query field within the same query. For example, the following query produces two fields (fullName and fullNameLength) where the second field is derived from the first.
    SELECT


    firstName & " " & MI & " " lastName AS fullName,
    Len([fullName]) AS fullNameLength
    FROM tblCustomer;

    This query works fine within Access but when I run the query remotely via PHP, I get a query error and it dies. The culprit seems to be the reference in the second field referring to the first field. Has anyone encountered this problem? Is there another way of referring to fields within the same query? Note, the above query is just an example. It would be easy to rewrite it to avoid the reference but I use this feature in a lot of other places and would like to know if there is something I am doing wrong.

    Thank you

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It has always been my experience that you cannot refer to an alias in a query. In this case I would have:
    Len(firstName & " " & MI & " " lastName) AS fullNameLength

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Select Query > Update Query > Table Field
    By tuggleport in forum Queries
    Replies: 2
    Last Post: 08-09-2012, 07:04 AM
  2. Replies: 5
    Last Post: 06-19-2012, 10:46 AM
  3. show name of query in query field
    By lmnnt in forum Queries
    Replies: 2
    Last Post: 05-24-2011, 08:01 PM
  4. Replies: 3
    Last Post: 06-03-2009, 07:15 AM
  5. Calculated Query Field used in different Query
    By cakdhooper in forum Queries
    Replies: 0
    Last Post: 11-21-2008, 03:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums