Artem,
Friday, October 25, 2002, 12:55:14 AM, you wrote:

AK> I have v.4.0.4b max nt, and I have the same result, even more:

AK> mysql> INSERT INTO settest SET chain="A,C";
AK> ERROR 1062: Duplicate entry 'A,C' for key 1
AK> mysql> INSERT INTO settest SET chain="C,A";
AK> ERROR 1062: Duplicate entry 'A,C' for key 1

AK> but

AK> mysql> SELECT * FROM settest WHERE FIND_IN_SET('C,A', chain)>0;
AK> Empty set (0.00 sec)

AK> I guess it can be a bug.

It's not a bug, it's a behaviour of a SET column type.

When you INSERT "C,A" in the settest, this value will be re-ordered to
"A,C" at first. As chain can contain only unique values, you get
"Duplicate entry" error.

There is no value "C,A" in the table, that is why you get an empty
result set. There is a mention about it in Paul DuBois's book (pg 106).

AK> -----Original Message-----
AK> From: Lopez David E-r9374c [mailto:r9374c@;motorola.com]
AK> Sent: Thursday, October 24, 2002 5:09 PM
AK> To: Mysql List (E-mail)
AK> Subject: Understanding MySQL column type SET


AK> Gurus

AK> I'm having trouble understanding the column type SET.
AK> To explain my problem, I'll create a table, populate
AK> it, and do selects.


AK> mysql> CREATE TABLE settest( chain SET( "A", "B", "C" ) NOT NULL,
AK>                       UNIQUE INDEX ichain( chain ) );

AK> mysql> INSERT INTO settest SET chain="A,C";

AK> mysql> SELECT * from settest;
AK> +-------+
AK> | chain |
AK> +-------+
AK> | A,C   |
AK> +-------+

AK> mysql> SELECT * FROM settest WHERE chain="A,C";
AK> +-------+
AK> | chain |
AK> +-------+
AK> | A,C   |
AK> +-------+

AK> mysql> SELECT * FROM settest WHERE chain="C,A";
AK> Empty set (0.00 sec)

AK>  or 

AK> mysql> SELECT * FROM settest WHERE FIND_IN_SET("C,A", chain);
AK> Empty set (0.01 sec)

AK> In reading MySQL Reference Manual, this second select statement 
AK> should work. But in version()=3.23.49-nt-log, it does not. 

AK> In my understanding of set theory, if a SET has A,B,C

AK>   A,C == C,A

AK> Can anyone tell me what I'm missing?

AK> BTW, for my application, I'm only interested in unique entries.
AK> ---
AK> David E Lopez


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com





---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to