Re: mysql question

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Alex Dean
Date:  
To: plug-discuss
Subject: Re: mysql question
Craig White wrote:

>perhaps the problem was that the table didn't have any unique indexes.
>
>anyway, update did the trick I needed...
>
>mysql> UPDATE horde_datatree_attributes SET attribute_value = \
>"Administrator" where datatree_id = "525";
>
>Thanks
>
>Craig
>
>
>

I figured it out. The error is because you have a syntax error in the
REPLACE query. It takes the same form as INSERT queries, not UPDATE
queries.

This would work, regardless of indicies : "REPLACE INTO
horde_datatree_attributes (datatree_id, attribute_value) VALUES (525,
'Administrator)"

But it probably isn't what you want. If there's no unique index, it
would insert a new row with the supplied values - and it sounds like an
UPDATE is really what you want.

I just wanted to point out that REPLACE doesn't care if there's a unique
index or not - it just has special rules to follow if one does exist.

thanks,
alex

>On Mon, 2005-02-28 at 08:38 -0700, Alex Dean wrote:
>
>
>>REPLACE shouldn't have given an error. If REPLACE doesn't find a match
>>on a unique index, it should just insert a new row, not cause an error.
>>Perhaps it's the double-quotes?
>>
>>alex
>>
>>Craig White wrote:
>>
>>
>>
>>>On Sun, 2005-02-27 at 23:14 -0700, Craig White wrote:
>>>
>>>
>>>
>>>
>>>>no unique index in this particular table...
>>>>
>>>>mysql> REPLACE INTO horde_datatree_attributes attribute_value VALUES \
>>>>"Administrator" where datatree_id = '525';
>>>>
>>>>ERROR 1064: You have an error in your SQL syntax near 'attribute_value
>>>>VALUES "Administrator" where datatree_id = '525'' at line 1
>>>>
>>>>how do I do this?
>>>>
>>>>
>>>>
>>>>
>>>----
>>>UPDATE - not REPLACE
>>>
>>>nevermind
>>>
>>>Thanks
>>>
>>>Craig
>>>
>>>---------------------------------------------------
>>>PLUG-discuss mailing list -
>>>To subscribe, unsubscribe, or to change you mail settings:
>>>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>>>
>>>
>>>
>>>
>>>
>>---------------------------------------------------
>>PLUG-discuss mailing list -
>>To subscribe, unsubscribe, or to change you mail settings:
>>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>>
>>
>
>---------------------------------------------------
>PLUG-discuss mailing list -
>To subscribe, unsubscribe, or to change you mail settings:
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>
>


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss