Error on deleting a record

[expired user #5259]'s profile image [expired user #5259] posted 13 years ago in General Permalink
If a table does not have a primary or unique field, heidisql shows error on deleting any record.

ansgar's profile image ansgar posted 13 years ago Permalink
How's the error message, please?
[expired user #5259]'s profile image [expired user #5259] posted 13 years ago Permalink
DELETE FROM `mysettings` WHERE `ShownLevel`= AND `SettingName`='dehde' AND `Value`='' AND `CategoryName`='' AND `ValueTypeName`='' AND `Hint`='' AND `Description`='' AND `Path`='' LIMIT 1;

/* SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND `SettingName`='dehde' AND `Value`='' AND `CategoryName`='' AND `ValueTypeNam' at line 1 */
[expired user #5259]'s profile image [expired user #5259] posted 13 years ago Permalink
http://www.cansarigul.com/heidi.png
ansgar's profile image ansgar posted 13 years ago Permalink
Hm, of which version/build are we talking about? If it's not the latest one, please update. If that problem also persists on the current build, please paste the SHOW CREATE TABLE result here, so I can reproduce that problem. Thanks.
[expired user #5259]'s profile image [expired user #5259] posted 13 years ago Permalink
I use the lastest version/build. You can see the screen capture on http://www.cansarigul.com/heidi.png


CREATE TABLE `mysettings` (
`ShownLevel` INT(5) UNSIGNED NOT NULL,
`SettingName` VARCHAR(50) NOT NULL COLLATE 'utf8_turkish_ci',
`Value` TEXT NOT NULL COLLATE 'utf8_turkish_ci',
`CategoryName` VARCHAR(255) NOT NULL COLLATE 'utf8_turkish_ci',
`ValueTypeName` VARCHAR(255) NOT NULL COLLATE 'utf8_turkish_ci',
`Hint` VARCHAR(50) NOT NULL COLLATE 'utf8_turkish_ci',
`Description` VARCHAR(500) NOT NULL COLLATE 'utf8_turkish_ci',
`Path` VARCHAR(255) NOT NULL COLLATE 'utf8_turkish_ci'
)
COLLATE='utf8_turkish_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
ansgar's profile image ansgar posted 13 years ago Permalink
Ah, got it: You had inserted one row and without some refresh you tried to update this new row, right? If you leave out some numeric value in a new row it looks like an empty string, not like "0". This empty string is not what's actually in the table - HeidiSQL just has not refreshed this row, which should probably be done after some INSERT. Not required after UDPATEs though but could be helpful. Will check if I can do that.
[expired user #5259]'s profile image [expired user #5259] posted 13 years ago Permalink
exactly as you said
ansgar's profile image ansgar posted 13 years ago Permalink
Could be that this is not posible in tables without primary key, as in your case. Probably doable with a
SELECT ... FROM table LIMIT <rowcount-1>, 1

but that would introduce an unstable behaviour, as there can easily be rows inserted between INSERT and SELECT so we don't get the right row. Shit.

Please login to leave a reply, or register at first.