Can't editing row data with a binary primary key?

I use binary uuids for keys. Is there a way to edit table data using the Mysql Workbench for this schema? I get:

UPDATE `db`.`table` SET `foo`='bar' WHERE `uuid`=?;

Which explicitly returns an error:

ERROR 0: Value not set for all parameters

I have no other way of referencing the lines I want to edit.

PhpMyAdmin fails as well while corrupting all binary data.

edit - for clarification, the data type of the actual keys is BINARY (16)

edit 2 - To clarify even more, this question concerns, in particular, MySQL Workbench. I understand the prepared statements.

edit 3 - I invest in this generosity in the hope that someone knows a workaround or solution.

+3
source share
1 answer

, :

SELECT *,HEX(uuid) FROM `db`.`table`;

:

uuid               foo      HEX(uuid)
---------------------------------------------------------------
E  |M_jE  |M_j     test     45ABFA057C4D5F6A45ABFA057C4D5F6A
.
.

, :

UPDATE `db`.`table` SET `foo`='bar' WHERE `uuid`=UNHEX('45ABFA057C4D5F6A45ABFA057C4D5F6A');

UPDATE `db`.`table` SET `foo`='bar' WHERE `uuid`=CAST(0x45ABFA057C4D5F6A45ABFA057C4D5F6A AS BINARY);
+8

Source: https://habr.com/ru/post/1774258/


All Articles