关于插入多个值 [英] About Inserting multiple values

查看:82
本文介绍了关于插入多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将从下拉列表中选择的多个int值插入由delimiter(,)分隔的单列中
与该值一起,还有其他一些行,其中插入了其他一些值

一张桌子有
预订ID,其中包含1
之类的值 和roomid包含值1,2,3

我如何使用SQL Server插入查询

i want to insert multiple int values selected from dropdown in to a single column seperated by a delimiter(,)
along with this values there are some other rows too in which some other values are inserted

a table has
Booking id which contain values like 1
and roomid which contain values like 1,2,3

how can i do it using sql server insert query

推荐答案

ritesh2712写道:
ritesh2712 wrote:

将从下拉列表中选择的多个int值插入到单列

insert multiple int values selected from dropdown in to a single column


由于从下拉列表中选择了逗号分隔的值,因此在发送该值进行SQL更新之前,请在服务器端的代码中将此值形成.

所以会是


Since the comma separated values are selected from a dropdown, form this value in code behind on server side before sending it for SQL update.

So it would be

INSERT INTO tableBook 
(BookingId, RoomId)
VALUES
(1,'1,2,3')


您需要规范化表.

创建一个新的表,该表现在具有bookingid和roomid-

预订ID-Roomid
-------------------
1-1
1-2
1-3
2-44

依此类推...
You need to normalize your table.

Create a new table which now has bookingid and roomid -

booking id - roomid
-------------------
1 - 1
1 - 2
1 - 3
2 - 44

and so on...


从下拉选择中解析int值@ FE将它们转换为另一个字符串变量,然后将其传递给BE查询...我们正在这样做,但是相反顺序....您能告诉您如何将值传递给BE吗?
Parse the int values from drop down selection @ FE convert them to another string variable and then pass it to BE query... we are doing this but in reverse order....can u tell how you are passing the values to BE?


这篇关于关于插入多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆