Mysql how to save a list of Ids in a column?

Asked

Viewed 179 times

0

How do I save a list in a column in Mysql? I mean, what kind of Mysql variable should I use?

I have a table in a Mysql database where I store some product information (size, Cód, etc.). One such information is the purchase notes for this product. Once the product is replenished in stock, there will be several notes for the same product, which I will need to list later. I have a table of "Notes" and a table of "Product".

I would like that in the "notes" column of the table "Product" I could save a list of Ids of the table "Notes".

  • 2

    Multi-valued fields are not a good idea .

  • 4

    I think it’s a little complicated for nothing. It would be much simpler to have a separate relationship table, or simply an extra field in the items of the notes to indicate which ones were consumed and which ones were not. There are many solutions to the problem you are mentioning, but this yours seems more complicated than all I’ve seen (which does not prevent your solution from being good for your individual case, after all, without seeing the rest of the system, can not really know). Even separating the stock by individual notes is easier than this (the entries in the stock correspond to the notes, with "consumption field").

  • Hi @Bacco. I tried to simplify what I wanted to say, but reading now, I think I complicated it for you. The notes I refer to are actually Pis(Proforma Invoice). Sometimes I need to know in which proformas have been purchased a certain item, so I need to have them related in some way. Whether you were consumed or not... I don’t care, understand? I am not able to relate and I will give a research on what you suggested (I am not a programmer, I need to learn in Rra). Thanks a lot, man! Abs

  • 1

    @Dtag think about this separate table. It’s almost the same thing you said, but it won’t record along with the other data. You will get the product id, the input id, and if you need another connection to the output notes.

  • @Bacco is, I’ll try that. Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.