How to find unique value using Select

66 views
Skip to first unread message

Rosario C

unread,
Jan 10, 2021, 11:41:40 AM1/10/21
to MapInfo-L
Happy New Year... 

I'm hoping someone can help me figure out how to find and select from a table a value that is unique, but can be an similar to some other value.. 

What i mean is, when I do a Select * From,  looking for a value like 46116, it returns 146116.

eNodeBID is my variable the user enters in from a form.. 

Column ( eNodeB_Tech) information looks like this; 46116 : 1900 LTE (15 MHz) & 2100 LTE & 700 LTE

the statement below is what I'm using.. 

Select * From strTabname where eNodeB_Tech Like "%"+eNodeBID+"%" into FindD

I'm wanting; 46116 : 1900 LTE (15 MHz) & 2100 

it returns: 134275 : 700 LTE & 600 NR (mMIMO) & 600 LTE | 146116 : 2.5 LTE | 57665 : 1900 LTE (15 MHz) & 2100 LTE

any help is appreciated/

RC

David Sherrod

unread,
Jan 10, 2021, 2:22:17 PM1/10/21
to MapInfo-L
Is SQL Select still an option in newer versions of Pro?  If so, then SELECT from yourtable for CONDITION WHERE YourColumn LIKE "46116"

That search would return only elements in YourColumn that are exactly 46116.
You could WildCard it thus, if you wished: YourColumn LIKE "%46116%" to find variations that include that string (would find 146116, for example).

Is this reply along the path you seek?

Dave Sherrod

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/1c419220-3b63-468f-b6b0-17a44f156c2fn%40googlegroups.com.

Rosario C

unread,
Jan 11, 2021, 9:04:59 AM1/11/21
to MapInfo-L
Dave, 

thanks for the reply, in turn, you made me rethink the statement i was using, and got it to work.. thanks

Regards,

RC

Warren Vick

unread,
Jan 11, 2021, 9:48:37 AM1/11/21
to mapi...@googlegroups.com

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

Rosario C

unread,
Jan 22, 2021, 9:09:57 AM1/22/21
to MapInfo-L
Warren, 

Thanks for your feedback.. I'm not that proficient MB, so I usually trial and error my way through it.. I'm still having issue finding a unique value within the string when its not first in the string... i cannot isolate each value unfortunately 

I thought by using Column eNodB_Tech :47900 : 2100 LTE & 700 LTE | 47839 : 2100 LTE & 700 LTE
and creating a new Column NB_csv: 47900,47839
i could use the following statement
Select * From strTabname where InStr(1,NB_csv,"+eNodeBID+")>0 into FindD

eNodeBID is a variable the user is searching for by way of a user form.. but this is not working.. 

again, any insight is appreciated.. 

regards,
RC

Peter Horsbøll Møller

unread,
Jan 22, 2021, 9:43:54 AM1/22/21
to mapi...@googlegroups.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

 

Peter Horsbøll Møller

www.precisely.com

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

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.

 

Rosario C

unread,
Jan 22, 2021, 12:37:19 PM1/22/21
to MapInfo-L
Peter....

Brilliant.. .. thank you.. working as intended.. i really appreciate the support... 

Regards, 

Rosario Conelli

Reply all
Reply to author
Forward
0 new messages