pulling stuff from comma-delimited field

M

middletree

I have a page where I allow the user to select one or more names of
employees to send an email to, which is sent automatically when the form is
submitted. I have a field called EmailSentTo, and if you sent it to Joe
Smith, then it stores the employee's number, 200, which is the PK of the
Employee table.

And there is, of course, another page which displays all the information
from that form I just submitted, so I want to display this new thing I
added, the name of the person I sent an email to. So far, no problem.

The thing gets complicated when I choose to send the email to more than one
person. In that case, I select Joe Smith and Mary Jones, and it enters
"200,100" into the field. A comma-delimited set of empoloyee IDs.

I realize that in order to display this, I would need some sort of loop, but
I'm not sure about how to do this. I can do a loop which pulls different
records from a table, but this is pulling several things from one field of
one record. Anyone got any sample code?

(BTW, I know that this is essentially a one-to-many, and I should simply
break it down to another table, but I was trying to avoid that. But I will
if that's the best thing to do)
 
G

Gerhard Pretorius

I am not sure I understand you correctly,

but you can use the split() function to split a string "100,200, 300" into
an array .
Or if you use that in a select statement use can use
select * from table where EmployeeID in (100,200,300)
then you can loop through that...

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top