Goodmorning everyone. Query Question (1 Viewer)

pawson

New member
Local time
Today, 02:02
Joined
Mar 19, 2020
Messages
23
Nice to meet you all.

I need to elaborate a query that is capable of removing products with an older version if a larger one is detected. For example:

Microsoft Project Professional 2010
Microsoft Visual Studio Standard 2019
Microsoft Project Professional 2012
Microsoft Visual Studio Standard 2009

So, the results should be like:

Microsoft Project Professional 2012
Microsoft Visual Studio Standard 2019

The thing is remove the products that the version is older.

Thanks :D
 

NauticalGent

Ignore List Poster Boy
Local time
Yesterday, 20:02
Joined
Apr 27, 2015
Messages
6,328
Do you want to uninstall an older program or remove/update a record in a table?
 

Gasman

Enthusiastic Amateur
Local time
Today, 01:02
Joined
Sep 21, 2011
Messages
14,260
I would have to do it as :

Create a query that is the MAX() of the name
Then a Select query that selects everything that is NOT in the MaxQuery (Just to make sure it works) :D
Then change the Select Query to a Delete Query. ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:02
Joined
May 7, 2009
Messages
19,230
is the 2009, 2012 part always on the Right side?

to Select in a Query:

select Field1 From Table As A Inner Join Table As B On
Left(A.Field1, InstrRev(A.Field1, " ")) = Left(B.Field1, InstrRev(B.Field1, " "))
Where (Right(A.Field1, Len(A.Field1)-InstrRev(A.Field1, " ")+1) >(Right(B.Field1, Len(B.Field1)-InstrRev(B.Field1, " ")+1)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:02
Joined
May 7, 2009
Messages
19,230
or simply:
Code:
select A.Field1 From [Tablename] As A Inner Join [Tablename] As B On
Left(A.Field1, InstrRev(A.Field1, " ")) = Left(B.Field1, InstrRev(B.Field1, " "))
Where Right(A.Field1, 4) > Right(B.Field1, 4)
 

pawson

New member
Local time
Today, 02:02
Joined
Mar 19, 2020
Messages
23
is the 2009, 2012 part always on the Right side?

to Select in a Query:

select Field1 From Table As A Inner Join Table As B On
Left(A.Field1, InstrRev(A.Field1, " ")) = Left(B.Field1, InstrRev(B.Field1, " "))
Where (Right(A.Field1, Len(A.Field1)-InstrRev(A.Field1, " ")+1) >(Right(B.Field1, Len(B.Field1)-InstrRev(B.Field1, " ")+1)
Yes, always in a right position
 

pawson

New member
Local time
Today, 02:02
Joined
Mar 19, 2020
Messages
23
or simply:
Code:
select A.Field1 From [Tablename] As A Inner Join [Tablename] As B On
Left(A.Field1, InstrRev(A.Field1, " ")) = Left(B.Field1, InstrRev(B.Field1, " "))
Where Right(A.Field1, 4) > Right(B.Field1, 4)
Thank you sir. But, which is the meaning A and B. are registers?
Kind regards
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:02
Joined
May 7, 2009
Messages
19,230
A and B are but Alias for the Same table (Tablename).
see the Query:

...[Tablename] As A ... [Tablename] As B
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:02
Joined
May 7, 2009
Messages
19,230
do delete Old Version
replace Table with the name of your table.
replace Field1 with the name of the field in your table.
Code:
DELETE Table.Field1, *
FROM [Table]
WHERE (((Table.Field1) In (SELECT A.Field1
FROM [Table] AS A Inner Join [Table] AS B
ON Left(A.Field1, InstrRev(A.Field1, " ")) = Left(B.Field1, InstrRev(B.Field1, " "))
WHERE (((Right([A].[Field1],4))<Right([B].[Field1],4)))
)));
 

Users who are viewing this thread

Top Bottom