View Full Version : Parsing a field and performing a lookup


mcgrcoAgain
07-23-2008, 12:13 AM
Hi there,

In my table one field has several codes to relect the fact that on equity can be listed on multiple indecies. It looks like this

;2;5;1;1;GF;1;LX;1;GD;1;SE;1;GB;


I have a table which contains all of these codes and a yes no flag. What is the best way of parsing this information and performing the lookup without needing to generate a new record for each of the index codes

What would be the best way of doing this?

Any help or tips would be appreciated.

regards
Conor

neileg
07-23-2008, 04:08 AM
You have a many to many relationship. The proper way to store this data is to use a junction table between your main table and the index table. Storing multiple items of data in the same field is always a bad move.

mcgrcoAgain
07-23-2008, 05:16 AM
Thanks Neil,

Unfortunatly that how the data is sent to me. I have no control over this. I need to find some way of extract these one by one and look them up on the index table

datAdrenaline
07-23-2008, 05:36 AM
The data is sent to you that way ... and that is fine ... but it sounds like you are trying to push that information into a different (local) table ... What is the structure of the destination if that is indeed what you are doing?

neileg
07-24-2008, 12:27 AM
I think the split function may help you on your way.