ronen
ronen

Reputation: 13

Insert Comma Separated Values to SQL

I would like to take a list that I have in a text file, of values which are separated by commas:

Example - 1,2,3,4,5,6,7,8,9,0

then put the values in a database table(I'm going to use this table for auto-complete with jQuery).

I would have done an array for the auto-complete but I have something like 1000 values so I think its better to pull from SQL(am i right?)

Try to explain it to me slowly cause I'm a novice and this is so confusing :)

Upvotes: 1

Views: 395

Answers (1)

Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53603

If those are 1000 constant values (like countries), put them in array.
If they are fairly dynamic, put them in a table
Assuming the table is called T1 and has one field F1, you need to transform the string 1,2,3,4,5,6,7,8....N to

INSERT INTO T1
VALUES (1),(2),(3),(4),(5),(6),(7),(8)......(N);

Upvotes: 2

Related Questions