0

I have a field call e-mails in my application. Now inside this field I want to hold 2 email addresses. When my webpage displays this field it should show as a hyperlink (with mailto) so when pressed it allows you to email directly.

E.g. the email field value is abc@test.com, efg@test.com

how can i 1.store the values as clickable links in one field? 2. Make sure they have the mailto syntax?

i tried storing the following in the email field but it wasnt correct

<a href="mailto:youremail@emailaddress.com">Email me</a>
abatishchev
  • 98,240
  • 88
  • 296
  • 433
ssrsnoob
  • 11
  • 3
  • look for `stuff for path xml` to solve it over sql and storing if is a different process in the application. – RoMEoMusTDiE Feb 22 '18 at 20:09
  • Why are you storing the entire hyperlink? You should be storing only the email address. And what you are trying to do is bad. It violates 1NF when you try to cram multiple pieces of information into a single tuple like that. Just don't do it. If you need multiple email addresses then you should have two rows in your email table. – Sean Lange Feb 22 '18 at 20:09
  • 1
    "inside this field I want to hold 2 email addresses. " That's a recipe for disaster. Read [Is storing a delimited list in a database column really that bad?](http://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad), where you will see a lot of reasons why the answer to this question is **Absolutely yes!** – Zohar Peled Feb 22 '18 at 20:15
  • for a single value how do i store a hyperlink value – ssrsnoob Feb 22 '18 at 20:29
  • What you have here isn't a SQL problem, it's a design problem. The database should be storing the data point, which is an email address. Multiple email addresses need multiple records, either in a single table or, more appropriately, in a related table. How that data point is displayed should be handled by the webpage. That's a rendering issue, and it's what HTML, CSS, etc. are best at. – Eric Brandt Feb 23 '18 at 13:38

1 Answers1

2

I think you should not store multiple emails in one field, instead, make another table for emails corresponding to the person, means relate PersonID to EmailID.

So your table Person will contain information about person and a PersonID (primary key) and table email will have EmailID (primary key), emailAddress and PersonID, PersonID being the foreign key.