简体   繁体   English

SQL 语句转储问题

[英]SQL Statement Dump Issue

I'm trying to find out why some of my order numbers in my table are dumping out there appropriate data while others aren't.我试图找出为什么我的表中的某些订单号会转储适当的数据,而其他人则不会。

Here I'm trying to dump out data from a specific order number and it won't dump its data for the COMPLEX CITY , COMPLEX NAME and ORDERNUM .在这里,我试图从特定订单号转储数据,但不会转储COMPLEX CITYCOMPLEX NAMEORDERNUM However, when I just select the columns it dumps there data and shows the corresponding data relating to the ordernum.但是,当我只选择列时,它会转储数据并显示与订单号相关的相应数据。

I'm using ColdFusion.我正在使用 ColdFusion。 Here is my code.这是我的代码。

<cfquery name="communities" datasource="pdoxtest">
 SELECT DISTINCT 
 [COMPLEX CITY] as COMPLEXCITY, 
 [COMPLEX NAME] as COMPLEXNAME,
 [COMPLEX ST] as COMPLEXST,
 [ORDERNUM]
 FROM SCHEDULE
 WHERE COMPLEXNAME = 'FORGE HOMESTEAD'
</cfquery>

<cfdump var="#communities#">

When I dump out this data it appears like this:当我转储这些数据时,它看起来像这样:

在此处输入图片说明 However, when I try to dump out a query like this:但是,当我尝试转储这样的查询时:

<cfquery name="test" datasource="pdoxtest">
 SELECT DISTINCT 
 [COMPLEX CITY] as COMPLEXCITY, 
 [COMPLEX NAME] as COMPLEXNAME,
 [COMPLEX ST] as COMPLEXST,
 [ORDERNUM]
 FROM SCHEDULE
 WHERE ORDERNUM = '144873'
</cfquery>

<cfdump var="#test#">

Nothing gets returned: Here is a screenshot:没有返回任何内容:这是屏幕截图:

在此处输入图片说明

I'm not sure what I'm doing wrong because when I enter a different ordernumber in the WHERE clause for a different COMPELXNAME data gets returned while some of the ORDERNUM doesn't like this one.我不确定我做错了什么,因为当我在WHERE子句中为不同的COMPELXNAME数据输入不同的COMPELXNAME会返回一些ORDERNUM不喜欢这个数据。

I guess it is sample of "WHAT YOU SEE IS NOT WHAT YOU GET":我想这是“你所看到的不是你得到的”的样本:

 SELECT DISTINCT 
 [COMPLEX CITY] as COMPLEXCITY, 
 [COMPLEX NAME] as COMPLEXNAME,
 [COMPLEX ST] as COMPLEXST,
 [ORDERNUM]
 FROM SCHEDULE
 WHERE ORDERNUM LIKE '%144873%';

I suspect that ORDERNUM column is text and you probably have some whitespaces/control characters.我怀疑ORDERNUM列是文本,您可能有一些空格/控制字符。

EDIT:编辑:

% is wildcard and it will match any characters. %是通配符,它​​将匹配任何字符。 I propose to copy value to some text editor like Notepad++, enable show all characters and check for spaces/carriage return/tabs and so on.我建议将值复制到 Notepad++ 等一些文本编辑器,启用显示所有字符并检查空格/回车符/制表符等。

You could think about cleansing data too.您也可以考虑清理数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM