Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

howto perform a partial match?

Status
Not open for further replies.

ollibr

IS-IT--Management
Mar 1, 2005
1
DE
I have to set up a query against an sql database which contains
information from our pbx. there is one table (called CALLS) which
contains all the calls made. Another table contains information about
called partners (DESTINATIONS)

I want to do a query on the CALLS table to sort out some calls by
a specific date for example. Additionally I want to resolve the called
number against the information from the DESTINATIONS table.

The issue is that in the DESTINATIONS table some entries exist only for
root numbers of called destinations.

For example when someone calls 920378123 this is stored in the CALLS table field DESTNUM

In DESTINATIONS there is a record

field value
NAME company_xyz
NUM 920378

which matches the called number excluding the pbx extension.

How can I integrate the information from the DESTINATIONS table
into the query on the CALLS table when I want the value of the
NAME field given back by the server?

Any comments are very welcome! thanks! Oliver
 
Assuming that NUM and destnum are numeric. If they are char, remove the cast expressions.

Code:
where cast(destnum as varchar(10)) =
substring(cast(NUM as varchar(10)) from 1 for 
char_length(cast(destnum as varchar(10)))

The substring and char_length functions may have a different syntax/name in your dbms.
 
You may also try:
WHERE destnum LIKE num || '%'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top