problem in many to many relationship

前端 未结 3 865
感情败类
感情败类 2021-01-28 02:37

I have two tables jewelry(j_id,j_name,Description) and style(style_id,style_name,image) each table has a many to many relationship with the other table

3条回答
  •  轮回少年
    2021-01-28 03:02

    Not sure that this is a database-design question. To me it looks more like a programming question and in that case it would be helpful to know what programming language and database you are using.

    Anyway here is some pseudo code that does what I think it is you are asking about.

    Add one row in table jewelry
    Store the new jewelry.j_id to a variable @jid
    
    for each @StyleID in SelectedStyleList
    begin
      Add one row to table jewelry_style 
       set jewelry_style.j_id=@jid, jewelry_style.style_id = @StyleID
    end
    

提交回复
热议问题