简体   繁体   English

SQL select查询不起作用。在ms访问2010

[英]SQL select query not working. in ms access 2010

enter image description here

here are my two charts and my query. 这是我的两个图表和我的查询。 Obviously you do see that some parameter names match. 显然你确实看到一些参数名称匹配。 but my query shows up as no results. 但我的查询显示没有结果。 WHY IS THAT? 这是为什么?

Thank you . 谢谢 。

Altho this query was made in access 2010 it also works in 2003 and 2007 虽然此查询是在Access 2010中进行的,但它也适用于2003年和2007年

if you cant read the query in detail. 如果你不能详细阅读查询。 just zoom in on this webpage 只需放大此网页即可

UPDATEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE: ****************************8 UPDATEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE:**************************** 8

thanks for all your help but i have solved it my own way. 谢谢你的帮助,但我已经用自己的方式解决了。 and because im doing this for work i needed it to be done fast and didnt have too much time to dela with why access trim does nto work =( ... i still dunno why. 并且因为我正在为工作做这件事我需要它快速完成并没有太多的时间来解决为什么访问修剪无法工作=(...我仍然不知道为什么。

but altho my source table is big that one did not have trialing spaces. 但是我的源表很大,没有一个试验空间。 only the parameter table which i had uploaded from another table that was an excel file and 99 rows. 只有我从另一个表上传的参数表是excel文件和99行。

i went back into the orignal excel file. 我回到了原始的excel文件。 tried a trim there. 试过修剪一下。 copy pasted the trimmed column and paste special values to rid of the formula and it still has the space!! 复制粘贴修剪的列并粘贴特殊值以摆脱公式,它仍然有空间! is this jsut an error on the trim function or what? 这个jsut是修剪功能的错误还是什么?

anyways instead i used a =left(cell,len(cell)-1) to rid of the one trailign space 无论如何,我使用a = left(cell,len(cell)-1)来摆脱一个trailign空间

then reuploaded the excel parameter table and now its working. 然后重新上载excel参数表,现在它的工作。 lengthy story but. 冗长的故事但是。 if anyone has another suggestions on why TRIM doesnt work please explain . 如果有人对TRIM无效的原因有另一个建议请解释。 i used LTRIM RTRIM. 我用过LTRIM RTRIM。 BOTH together and jsut TRIM 同时和jsut TRIM

In a reply to @flayto you said "*turns out there is one trailing space behind each Parameter_Name value in ParameterTable. But i tried trimming in it does say it updates all of the entries in that table yet the one space sitll does not go away!*" 在对@flayto的回复中,你说“*结果是在ParameterTable中每个Parameter_Name值后面都有一个尾随空格。但我试过修剪它确实说它更新了该表中的所有条目但是一个空格不会消失!*”

A few times I have copied a range of cells from an Excel spreadsheet into Access tables. 有几次我将Excel电子表格中的一系列单元格复制到Access表格中。 The data in Access included invisible trailing characters after the text I expected. Access中的数据包含我预期的文本后面的隐藏尾随字符。 Since those characters were not spaces, they were not removed by the Trim() function. 由于这些字符不是空格,因此Trim()函数不会删除它们。 See what you actually have following the Paramater_Name values. 查看Paramater_Name值后面的实际内容。

SELECT
    Parameter_Name,
    Len(Parameter_Name) AS Length_of_Parameter_Name
    Asc(Right(Parameter_Name, 1)) AS rightmost_character
FROM ParameterTable;

The fix will depend on what you find. 修复程序取决于您找到的内容。 For example, if there is always one and only one unwanted character, you could discard it with this UPDATE statement: 例如,如果总有一个且只有一个不需要的字符,则可以使用此UPDATE语句将其丢弃:

UPDATE Parameter_Table
SET Parameter_Name = Left(Parameter_Name, Len(Parameter_Name) -1);

Whatever UPDATE you try, make sure to backup the database first in case anything goes wrong. 无论您尝试更新什么,请确保先备份数据库,以防出现任何问题。

Because you're comparing ParameterTable.Full_Name to T1_SourceTable.Parameter_Name . 因为您将ParameterTable.Full_NameT1_SourceTable.Parameter_Name进行比较。

You should be comparing ParameterTable.Parameter_Name to T1_SourceTable.Parameter_Name . 您应该将ParameterTable.Parameter_NameT1_SourceTable.Parameter_Name进行比较。

***NOTE: I'm leaving this up while I look at this, but I'm suspecting the leading/trailing spaces (as mentioned by a couple of others). ***注意:我在看这个时就把它留下了,但是我怀疑是领先/尾随空间(正如其他几个人所提到的那样)。

***Possible other solution: Modify this into a specific Inner Join. ***可能的其他解决方案:将其修改为特定的内部联接。 The links I'm finding from MS don't specifically you can't do what you've done, but they do all use the explicit INNER JOIN Syntax. 我从MS找到的链接没有具体你不能做你已经做过的事情,但他们都使用显式的INNER JOIN语法。

So you might try: 所以你可以试试:

SELECT T1.Full_Name, T2.Parameter_Name
FROM ParameterTable T1
INNER JOIN T1_SourceTable T2
  ON T1.Parameter_Name = T2.Parameter_Name

This shouldn't, as far as I know, actually change anything- but, based on the links I'm finding, you might try it out. 据我所知,这不应该改变任何东西 - 但是,基于我找到的链接,你可能会试一试。

Are you sure there are no leading or trailing spaces in the field values? 您确定字段值中没有前导或尾随空格吗? Try wrapping each field with LTRIM/RTRIM as in LTRIM(RTRIM(T1_SourceTable.Parameter_Name)) just to be sure that isn't the problem. 尝试使用LTRIM(RTRIM(T1_SourceTable.Parameter_Name))中的LTRIM / RTRIM包装每个字段,以确保不是问题。

Are they the exact same data type? 它们是完全相同的数据类型吗? If not, for Access, try using LIKE instead of equals. 如果没有,对于Access,尝试使用LIKE而不是equals。

t1.parameter_name like t2.parameter_name t1.parameter_name与t2.parameter_name类似

See the example here. 请参阅此处的示例。 http://office.microsoft.com/en-us/access-help/access-sql-where-clause-HA010278156.aspx http://office.microsoft.com/en-us/access-help/access-sql-where-clause-HA010278156.aspx

If your table is linked and the underlying datatype is char rather than varchar, then it will be blank padding even after you think you have trimmed it. 如果您的表是链接的并且基础数据类型是char而不是varchar,那么即使您认为已经修剪它,它也将是空白填充。 You'll have to change the underlying data type or join on trim(parameter_name) which will be expensive! 您将不得不更改基础数据类型或加入trim(parameter_name),这将是昂贵的!

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

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