Results 1 to 4 of 4
  1. #1
    dudumomo is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    5

    Query "Not Alike"


    Hi,

    I have a product references table where I want to remove all the references starting by "ABC-"
    The list to exclude is in another table.

    It simple to exclude a direct match (Left Join + Is Null) but I have no idea on how to exclude not a direct match but "Starting With" match.

    Any idea?

    Thank you

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    You would need a query along these lines

    UPDATE tblProdRef, tblOther
    SET tblProdRef.Reference=""
    WHERE tblProdRef.Reference like tblOther.Reference & "*"

    If this is not what you require, provide some example data for both tables and the required end result

  3. #3
    dudumomo is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    5
    Thanks for your feedback.

    I'm having some difficulties (Quite new to SQL).

    Here is what I'm using now.
    Code:
    SELECT [Y Orders with Pyramids].[Reporting 1], [Y Orders with Pyramids].[Reporting 3], [Y Orders with Pyramids].Material, [Delta Price Reference Matching].[New reference], IIf(IsNull([New reference]),[Material],[New reference]) AS [Clean ref], Sum([Y Orders with Pyramids].[Market View =S=]) AS [SumOfMarket View =S=], Sum([Y Orders with Pyramids].Qty) AS SumOfQty, Sum([Market View =S=])/Sum([Qty]) AS [NSP Y]
    FROM ([Y Orders with Pyramids] LEFT JOIN [Delta Price Reference Matching] ON [Y Orders with Pyramids].Material = [Delta Price Reference Matching].[Old reference]) LEFT JOIN [Delta Price Reference to excludes] ON [Y Orders with Pyramids].Material = [Delta Price Reference to excludes].Reference
    WHERE ((([Y Orders with Pyramids].Month)<=[Select Y month]) AND (([Y Orders with Pyramids].Country)="Vietnam") AND (([Y Orders with Pyramids].[Reporting 2])="Transactional") AND (([Y Orders with Pyramids].[Salesteam / Order])<>"Intercompany"))
    GROUP BY [Y Orders with Pyramids].[Reporting 1], [Y Orders with Pyramids].[Reporting 3], [Y Orders with Pyramids].Material, [Delta Price Reference Matching].[New reference], IIf(IsNull([New reference]),[Material],[New reference])
    HAVING ((([Y Orders with Pyramids].Material) Not Like [Delta Price Reference To Excludes].[Reference]) AND ((Sum([Y Orders with Pyramids].[Market View =S=]))<>0));
    But it doesn't work (Syntax error). If I remove the HAVING ([Y Orders with Pyramids].Material) Not Like [Delta Price Reference To Excludes].[Reference]) it works well.
    Not sure where to put it then.

    Thanks for your help !

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    you wont be able to do an update with a group by query, try changing it back to an 'normal' query

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

Similar Threads

  1. Replies: 6
    Last Post: 06-24-2016, 06:07 AM
  2. Replies: 4
    Last Post: 12-20-2015, 12:16 PM
  3. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  4. Replies: 1
    Last Post: 07-10-2015, 06:33 AM
  5. Replies: 1
    Last Post: 02-05-2015, 05:41 PM

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