Hi
How do i write multiple values in a single column, using INSERT INTO
I have a listbox and i want all the selected values from that listbox inserted into a table column
INSERT INTO Orders(OrderID, Items) VALUES ____?????______ __
Do i need to run the above statement in a loop?
Thanks
qi
3 13888 code green 1,726
Recognized Expert Top Contributor - INSERT INTO Orders(OrderID, Items) VALUES ____+________
ck9663 2,878
Recognized Expert Specialist
If you need to have all the selected from your listbox in different rows, yes you need to issue multiple insert statements.
--- CK
As far as I understand, the problem is something like this. For Order Id 1, there can be 3 Items(say Item1,Item2,Ite m3)
For Order Id 2, there can be 5 Items(say Item 1.. Item5, all are comma seperated).
Next you want to insert the values into your database table
So the output will be like
TblOrders OrderID Items
---------- --------
1 Item1,Item2,Ite m3
2 Item1,Item2,Ite m3,Item4,Item5
If that is supposed to be the case, handle all the list box items from your Frontend applications all at a time.
I mean to say before passing to the SQL QUERY, you should send the values as, 1 for OrderId filed while Item1,Item2,Ite m3 for Item field.
So in that case the SQL STATEMENT will be - INSERT INTO Orders(OrderID, Items) VALUES (1,' Item1,Item2,Item3');
You don't have to write any loop in the STORED PROC . Handle from your Frontend application.
Hope this helps.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jack |
last post by:
I have a text file of data in a file (add2db.txt) where the entries are
already entered on separate lines in the following form:
INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere.
Good food.", " (Harry Houdini - 03/01/2004)");
INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada",
" (Herbert Hoover - 03/03/2004)");
INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
|
by: RotterdamStudents |
last post by:
Hello there,
i have a strange problem. I can't get php to insert multiple rows at once in
a MySQL database. I use the
$sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d',
'$e')";
I want to insert 5 rows at a time in the database, but it only inserts every
5th record. For example:
1. AA
|
by: Cliff |
last post by:
I'm trying to do multiple insert statements. The table looks like
this:
CREATE TABLE $table (CNTY_CNTRY_CD char(3),ST char(2),
CNTY_CNTRY_DESCR varchar(50),CNTY_CNTRY_IND char(1),
HOME_CNTRY_IND char(1),
CONSTRAINT cnty_key PRIMARY KEY (CNTY_CNTRY_CD, ST))
I'm using 2 fields for the primary key constraint
My insert statement looks like this:
|
by: hartley_aaron |
last post by:
Hi,
I have an application running on a wireless device and being wireless I
want it to use bandwidth as efficiently as possible. Therefore, I want
the SQL statement that it uploads to the SQL Server to be as efficient
as possible. In one instance, I give it four records to upload, which
currently I have as four seperate SQL statements seperated by a ";".
However, all the INSERT INTO... information is the same each time, the
only that...
|
by: Elroyskimms |
last post by:
I have a table using an identity column as its Primary Key and two
columns (table reduced for simplicity) EmployeeNumber and ArrivalTime.
CREATE TABLE (
IDENTITY (1, 1) NOT NULL ,
(10) COLLATE SQL_Latin1_General_CP1_CI_AS
NOT NULL ,
NOT NULL ,
CONSTRAINT PRIMARY KEY CLUSTERED
(
| |
by: Florence HENRY |
last post by:
Hello,
well, almost everything is in the subject !
I have to fill 2 tables (more complicated than in the example !):
CREATE TABLE A (
id serial primary key,
foo text);
|
by: Geoffrey KRETZ |
last post by:
Hello,
I'm wondering if the following behaviour is the correct one for
PostGreSQL (7.4 on UNIX).
I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching
the following request :
INSERT INTO temp_tab VALUES (1,2,3)
|
by: rn5a |
last post by:
During registration, users are supposed to enter the following
details: First Name, Last Name, EMail, UserName, Password, Confirm
Password, Address, City, State, Country, Zip & Phone Number. I am
using MS-Access 2000 database table for this app. Note that the
datatype of all the fields mentioned above are Text. Apart from the
above columns, there's another column in the DB table named
'RegDateTime' whose datatype is Date/Time which is...
|
by: deejayquai |
last post by:
Hi
I'm attempting to insert multiple records from one table into another
based on rows selected in a multiple list box. This all seems to be
working OK until I get to a field where the value is null. What seems
to happen then is the entire record isn't inserted into the new table
ie it fails. The field called is 95% of the time empty but
occassionally has been filled in, so I think I need something in the
code that covers both...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |