mysql SUBSTR() 问题
今天早上很简单的一件事。
好的,这是我的小 sql
语句
SELECT SUBSTR(quote,1,20) FROM b_quotes WHERE id='74'
这返回一个空结果,这很令人困惑,因为如果我调用该记录的任何其他部分(例如客户的电子邮件地址),它会完美返回。我尝试过各种变体,但似乎总是 SUBSTR 部分失败。
有人能解释一下吗?
谢谢 谢恩
Nice easy one for this morning.
Ok, here's my little sql
statement
SELECT SUBSTR(quote,1,20) FROM b_quotes WHERE id='74'
This is returning an empty result which is confusing because if I call upon any other part of that record (the customers email address for example) it returns it perfectly. I've tried variations and it always seems to be the SUBSTR part that is failing.
could anyone shed some light on this?
Thanks
Shane
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您尚未指明报价列使用哪种数据类型,请尝试以下操作:
Since you haven't indicated which data type is used for the quote column, try this:
尝试 SELECT SUBSTR(quote,1,20) AS q FROM b_quotes WHERE id='74'
Try
SELECT SUBSTR(quote,1,20) AS q FROM b_quotes WHERE id='74'
quote
列的数据类型是什么?如果是 CHAR 或 VARCHAR,它的长度是多少?您使用什么代码来访问从数据库返回的数据?您的 SQL 语句是正确的,因此如果您想避免解决方法并且只想知道为什么您的查询似乎不起作用(如您所问),您必须研究应用程序代码中的问题。
What's the datatype of the
quote
column? If it's a CHAR or VARCHAR, what's its length? What code are you using to access the data returned from the database?Your SQL statement is correct, so if you want to avoid workarounds and just want to know why your query doesn't seem to work (as you asked) you have to research problems in your application code.