Results 1 to 4 of 4
  1. #1
    pradeepkumar089 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    5

    Need Help in query

    Hi There! I am trying to name my query result to specific name for instance if my first name contains "Gary*" say last column Bad/Good name: " Good name" if not say "Bad name". I used below query with Union function but it partially works. Gary comes under both Good name and bad name. Please help to fix

    SELECT Customer.CustID, Customer.FirstName, Customer.LastName, Orders.OrderNo, Orders.OrderDate, Orders.Subtotal, "Good name" AS [Good name or Bad name]


    FROM Customer INNER JOIN Orders ON Customer.CustID = Orders.CustID
    WHERE (((Customer.FirstName) Like "Gary*"))
    UNION
    SELECT Customer.CustID, Customer.FirstName, Customer.LastName, Orders.OrderNo, Orders.OrderDate, Orders.Subtotal, "Bad name" AS [Good name or Bad name]
    FROM Customer INNER JOIN Orders ON Customer.CustID = Orders.CustID
    WHERE (((Customer.FirstName) <> "Gary*"));

    Click image for larger version. 

Name:	Capture5.JPG 
Views:	14 
Size:	156.8 KB 
ID:	25911

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    In the second, <> should be Not Like
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pradeepkumar089 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    5
    Quote Originally Posted by pbaldy View Post
    In the second, <> should be Not Like
    Thank you so much :-) it worked

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

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