468,241 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,241 developers. It's quick & easy.

csv, array or alternative in mysql table?

im sort of a newbie to all of this and my terminology isnt accurate but
i have a couple simple questions. ive been looking around for a way to
insert multiple and seperate strings (like an array or a csv file)
inside of one row "cell" in a MySQL table. for examlpe id like to
insert "review1..., review2..., review3..., review4..." inside a row
"cell". id also like to be able to do a loop on them so i can format
each string. is it possible to insert an array into a "cell"? anyway,
if you could direct me in the right direction, i can figure the rest
out for MySELF. THANKS!

Jul 17 '05 #1
3 1837
kiqyou_vf wrote:
im sort of a newbie to all of this and my terminology isnt accurate but
i have a couple simple questions. ive been looking around for a way to
insert multiple and seperate strings (like an array or a csv file)
inside of one row "cell" in a MySQL table.
for examlpe id like to
insert "review1..., review2..., review3..., review4..." inside a row
"cell". id also like to be able to do a loop on them so i can format
each string. is it possible to insert an array into a "cell"? anyway,
if you could direct me in the right direction, i can figure the rest
out for MySELF. THANKS!


I have no idea about MySQL but Postgres does this. I'm guessing thats not
an option for you.

There are about a million reasons why you do not want to do this. The
normal approach is to create a second table and put each value into a row
in that table, something like this:

create table parent (
somekey char(10),
..other columns..)

create table child (
somekey char(10),
column1 char(10))

The idea is that the common column "somekey" links values from the child to
the parent.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 17 '05 #2
i THINK i see what your sayin, each row on the child table is linked to
a certain column in the parent table?

Jul 17 '05 #3
kiqyou_vf wrote:
i THINK i see what your sayin, each row on the child table is linked to
a certain column in the parent table?


Yes, that's it. In PHP you can loop through these with code like the
following (assuming postgres, substitute mysql or whatever as appropriate):

$results = pg_query(
"select column1
from child
where somekey = '$valueofinterest'");
while ($row = pg_fetch_array($results) {
...do something with entry
}

Buy one of Celko's books on db design, or ask a lot of questions over in
comp.databases, it will really be a big help.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Raptor | last post: by
4 posts views Thread by Haydnw | last post: by
2 posts views Thread by chrisoftoday | last post: by
5 posts views Thread by Chris H | last post: by
2 posts views Thread by rjames.clarke | last post: by
2 posts views Thread by mouac01 | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.