Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-23 : 08:55:23
vamsi writes "Well i have written a query using the left and the charindex function to return the country_names of a particular number by extracting the country code from phone number

eg: if the phone number is 1-800-8269 the query will return america by extracting the 1 from the number and passing the number to a different table where i have the country names and the country codes.

i should get the result in the following manner as



Name duration Phone_number Country

john 30 1-800-8269 USA

linda 100 91-897-54585 india

i have two different tables in one table the information is like

name dur phone_number rate
john 30 1-800-8269 50

linda 100 91-897-54585 150


the other table

ccode country
1 USA
91 India
44 UK



How do i do that ??"

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2002-07-23 : 09:19:59
Looks up JOIN in BOL

Peace

Rick

Go to Top of Page

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-07-23 : 09:47:20
A further hint is in your join statement, user your left(column,charindex()) function = ccode from the other table.

Using an join and the above, you should be able to accomplish want you need.

Jeremy



Go to Top of Page
   

- Advertisement -