Re: Re: enum !!
| From: | (Miles Thompson) | Date: | Mon, 16 Jul 2001 19:54:41 +0000 |
| Subject: | Re: Re: enum !! | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-10463@lists.php.net to get a copy of this message | ||
Yes, that syntax is OK if you EXACTLY match the structure of the table. If you redesign the table and insert a column between name and cat, your data will go into the new field. For that reason I prefer
insert into test set name = "shen", cat = "a,c"
Yes, one insert statement per line. To do multiple inserts you could store the values in an array and then set up a loop to process the array, one insertion per row.
You could extend that to open and read a text file,
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.fgets.php
parsing each line into an array
http://www.php.net/manual/en/function.split.php
or
http://www.php.net/manual/en/function.explode.php
and using your array processing code to do the rest.
Have fun - Miles Thompson
At 03:00 PM 7/16/01 -0400, McShen wrote:
BTW, did i insert those data correctly? here was what i type insert into test values('shen','a,c'); insert into test values('shen1','a,c'); I think they were wrong. How do i insert 2 values ? "McShen" <hshen@crosswinds.net> wrote in message news:20010716184844.89676.qmail@pb1.pair.com... ok. I use set to make a table. here is my table 'test' +-------+------+ | name | cat | +-------+------+ | shen | a,c | | shen1 | b,c | +-------+------+ How can I find all records that contain 'c'? i tried select * from test where cat='c'; it returned "empty set"; please help "Tom Hodder" <t.hodder@globalgold.co.uk> wrote in message news:NOEMKHKHBPNACMAIJAPECEPMCCAA.t.hodder@globalgold.co.uk...First normal form (1NF), A table in which the intersection of everycolumnand record contains one, and only one, value. -----Original Message----- From: Hugh Bothwell [mailto:hugh_bothwell@hotmail.com] Sent: 16 July 2001 19:21 To: php-db@lists.php.net Subject: [PHP-DB] Re: enum !! "McShen" <hshen@crosswinds.net> wrote in message news:20010716174257.47906.qmail@pb1.pair.com...and Ihow do i store multiple data in one field? i have a table like this +-------+-------------------+------+-----+---------+-------+Your query is mixed up; 'test' is the field name, not the table name,| Field | Type | Null | Key | Default | Extra |+-------+-------------------+------+-----+---------+-------+| test | enum('a','b','c') | YES | | NULL | |+-------+-------------------+------+-----+---------+-------+ insert into test values('a','b','c'); doens't work. please helpthink you want to put the values into three separate records, not one... Try INSERT INTO tablename ( test ) VALUES ( 'a' ), ( 'b'), ('c'), (''); This should get you four records, with 'test' values of a, b, c, andnull.If you want to store more than one value in the same record, you shouldbelooking at sets, not enums. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net