Hello RC,
I’m pleased to see you’ve resolved your issue, but this type of problem is commonplace. The challenge is that multiple elements of information has been encoded into a string field in your tables for convenience. Later, there is a need to extract or search by an element of string. I presume the starting number in “46116 : 1900 LTE (15 MHz) & 2100 LTE & 700 LTE” is a key identifier (cell ID?) or similar? It would be much better to have that factored out into its own field as this would make your queries quicker and more precise.
If there’s nothing you can do about the data, the challenge is to find a query that executes in a reasonable time (given the size of the table) and doesn’t give any false positives. As you’ve probably discovered already the “%46116%” will match things which contain 46116. If you know that the ID is always at the beginning of the string, you could drop the first %. This would then mean “starts with”, but would still match “46116999”, etc. If you have single digit IDs in your data, then a search for “1%” may match a lot of records! You can delimit things if its guaranteed that there’s a space-colon after each ID in the string. e.g. “46116 :%” All these methods make assumptions on the data which almost inevitably will break at some point since (unless it’s well documented) a developer will not assume that the format of the cell summaries is critical. So, if possible, try to keep the essential elements separated.
Regards,
Warren Vick
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/ead4ada6-0869-4562-8187-d403d2c81e02n%40googlegroups.com.
Hi RC,
You’d be better of using to conditions in you query:
1. One to find the string in the beginning
2. One to find the string not in the beginning.
Select * From strTabname
Where Left$(eNodB_Tech, Len(eNodeBID + " :")) = eNodeBID + " :"
Or eNodB_Tech Like "%| " + eNodeBID + " :%"
Into FindID
The logic above is that either
1. the given ID added " :" matches the first part of the string. I have added a space in front of : assuming that always will be the case
2. the given ID added "| " in front and " :" After will be matched somewhere in the string. Again note the spaces inside the “”.
You need to include the : and | to make sure you don’t find an ID that holds part of the ID the user is searching for
I hope this helps
From: mapi...@googlegroups.com <mapi...@googlegroups.com>
On Behalf Of Rosario C
Sent: 22. januar 2021 15:10
To: MapInfo-L <mapi...@googlegroups.com>
Subject: Re: [MI-L] How to find unique value using Select
This message originated Externally. Use proper judgement and caution with attachments, links, or responses. |
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/7cb2a00b-115b-4e93-ae47-7d1da9213bean%40googlegroups.com.