如何在SQLite中使用GUID值删除行 [英] How to DELETE a row with a GUID Value in SQLite

查看:77
本文介绍了如何在SQLite中使用GUID值删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SQLite的GUID类型中有一列,我已经尝试过这样的查询,但它没有返回错误,但是该行并未被删除

I have a column in SQLite of GUID type, I have tried a query like this, and it returns no error, but the row is not deleted

DELETE FROM MyTable WHERE Id='4ffbd580-b17d-4731-b162-ede8d698e026';

在SQLite浏览器中,Id值看起来像二进制值,它们具有奇怪的字符.

In SQLite Browser the Id values look like binary values, they have strange characters.

我也尝试过这种方法,但仍然无法正常工作

I also have tried this, but still does not work

DELETE FROM MyTable WHERE Id='{4ffbd580-b17d-4731-b162-ede8d698e026}';

推荐答案

我知道我迟到了,但是对于有相同问题的人来说可能很有用.

I know I'm late for this, but it might just be useful for someone with the same problem.

我的一个表中具有唯一列类型的列,并且当我在没有任何条件的情况下执行选择查询时,它将以这种格式返回结果guid列值-

I have a uniqueidentifier type of column in one of my tables and when I execute a select query without any conditions, it returns the result guid column values in this format -

{000B6A69-04D6-C557-7EA3-08CF8C8AD84B}

{000B6A69-04D6-C557-7EA3-08CF8C8AD84B}

(是的,带大括号)

我发现使用typeof()函数将我的guid列值存储为文本.因此,我只是尝试了四种不同的陈述,幸运的是,第四条陈述奏效了-

I found out using typeof() function that my guid column values had been stored as text. So, I just tried out four different statements and luckily, the 4th one worked -

    1. select myGuidColumn, typeof(myGuidColumn) from MyTable WHERE [myGuidColumn] = '000B6A69-04D6-C557-7EA3-08CF8C8AD84B' --didn't work
    2. select myGuidColumn, typeof(myGuidColumn) from MyTable WHERE [myGuidColumn] = '{000B6A69-04D6-C557-7EA3-08CF8C8AD84B}' --didn't work
    3. select myGuidColumn, typeof(myGuidColumn) from MyTable WHERE [myGuidColumn] LIKE '{000B6A69-04D6-C557-7EA3-08CF8C8AD84B}' --didn't work
    4. select myGuidColumn, typeof(myGuidColumn) from MyTable WHERE [myGuidColumn] LIKE '000B6A69-04D6-C557-7EA3-08CF8C8AD84B' --it works!

这篇关于如何在SQLite中使用GUID值删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆