0

I work on multiple projects, especially a web one.

And actually when I need to store like many 'tag' ( its an example ) in one variable, I do it this way:

INSERT INTO xxx (tag) VALUE ('tag1;tag2;tag3')

I use separator. The fact is its a bit crap but it works. I know its not the best solution. When I need to SELECT I cant use WHERE tag=tag1 because of the separator.

What guys do you use when you need to store many value in one var ?

oxmolol
  • 125
  • 1
  • 1
  • 10
  • 2
    Do ***not*** store delimited values in a single column. Read up on database normalization and one-to-many relationships. Also: which DBMS are you using? Postgres? Oracle –  Jul 26 '15 at 11:30
  • You may use different columns for them if the values are limited, otherwise use new row to store each new value. You can even break tag and key value in a entire different table, whose only columns be tag and value. This way if your original table had other columns also, they won't need to be repeated in case you are using different rows. Read about 2nd level normalization. – Abhishek Bhardwaj Jul 26 '15 at 11:32
  • 1
    "The fact is its a bit crap but it works." If you stay with it, you will discover more and more crap coming out. Multiple values need to go into multiple rows of a different table. – Sergey Kalinichenko Jul 26 '15 at 11:34
  • So you guys recommend me to create for each multiple solution a base related from this id ? is it the best solution ? – oxmolol Jul 27 '15 at 16:20

0 Answers0