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)
 Sql Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-17 : 07:56:06
srini writes "i have one zipfield which is having data like below one

id zip
1 011,022,202
2 055,078,985
3 022,555,454


i need to find out the id who is having 022 as zip in that table i dont know how to seperate one field data with , within that table

Regards
srini"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-06-17 : 07:59:35
SELECT * FROM myTable WHERE zip LIKE '%022%'

Do yourself a huge favor, modify your data so that you store zips like this:
id   zip
1 011
1 022
1 202
2 055
2 078
2 985
3 022
3 555
3 454
Your query then becomes:

SELECT * FROM myTable WHERE zip ='022'

It will perform far better, especially for larger tables. Storing the zips as you have them now will prevent SQL Server from effectively indexing them and will sacrifice performance.
Go to Top of Page
   

- Advertisement -