简体   繁体   English

如何在JOIN语句中使用WHERE和LIKE子句

[英]How to use WHERE and LIKE clause with JOIN statement

I'm trying to perform a JOIN on two tables, which works fine by itself. 我正在尝试在两个表上执行JOIN ,它本身可以正常工作。 But if I then try to add a WHERE x LIKE '%abc%' , it doesn't work. 但是,如果我随后尝试添加WHERE x LIKE '%abc%' ,则此方法将无效。

For example: 例如:

SELECT tbd.primarytitle, trd.averagerating  
FROM tbd  
INNER JOIN trd 
ON tbd.tconst = trd.tconst 
WHERE tbd.primarytitle LIKE '%A%'

I've tried going through all kinds of joins, and I've tried parenthesizing the first part and assigning to a table, then performing the WHERE x LIKE on that table, and no luck. 我尝试过各种连接,尝试将第一部分括起来并分配给表,然后在该表上执行WHERE x LIKE ,但没有运气。

How can I achieve this? 我该如何实现? I've tried looking at 6-7 articles but none of them address both WHERE and LIKE after a JOIN . 我尝试看了6到7篇文章,但是在JOIN之后,它们都没有同时解决WHERELIKE的问题。

The issue is the environment being used for the SQL. 问题是用于SQL的环境。 In MS Access, you have to use * instead of % for wildcards. 在MS Access中,通配符必须使用*代替% Simply switch the two and the query will return records. 只需将两者切换即可,查询将返回记录。

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

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