Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Filtering in a Union Query (Access 2000 >)

    Hi all,

    I am having problems trying to filter records in a union query. Is this actually possible? I seem to have all the syntax correct according to SQL, but it keeps on throwing out a parameter box!!!!

    Here is the SQL:
    SELECT customers.[first name] AS FN, customers.[last name] AS LN, customers.title AS TLE, customers.[Work Phone] AS PH, "Cust" AS REL
    FROM Customers
    UNION SELECT employees.firstname,employees.lastname, employees.title, employees.homephone, "Empl"
    FROM Employees
    WHERE LN Like "C*"
    ORDER BY TLE;

    Tx
    Regards,
    Rudi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filtering in a Union Query (Access 2000 >)

    The WHERE part only applies to the immediately preceding SELECT statement, not to the union as a whole. LN is not a field name in the second SELECT statement. If you want to filter the union query as a whole, save the union query without a WHERE clause, then create a new query based on the union query, and add criteria there.Alternatively, add the appropriate WHERE clause (with the correct field names) to *each* of the SELECT statements in the union query.

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Filtering in a Union Query (Access 2000 >)

    Awesome....you could not have made that clearer....tx!
    Regards,
    Rudi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •