如何过滤 SQL Server 数据库查询中的值?
我有一个针对 MySQL 数据库运行良好的查询,但我们必须将数据库和应用程序迁移到 SQL Server。现在我在让这个查询工作时遇到了麻烦。
SELECT
complist.CompName,
complist.CompID,
componenttrace.Remark,
complist.McID,
complist.Station,
complist.Slot,
complist.Amount - complist.Used - ISNULL(complist.Correction,0)
FROM
complist, componenttrace
WHERE
complist.McID = 1004
AND complist.CompID = componenttrace.CompID
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
ORDER BY
complist.CompName, complist.CompID
该部分
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
在应用程序上,如果给定字段(即 1.1
)上有任何值,则会自动添加
。我有 SQL 语法问题,但不知道如何解决。任何人都可以在这里阐明一些情况吗?
谢谢,
古斯塔沃
I've a query that works OK against a MySQL database, but we've had to migrate the database and applications to SQL Server. Now I'm in trouble getting this query to work.
SELECT
complist.CompName,
complist.CompID,
componenttrace.Remark,
complist.McID,
complist.Station,
complist.Slot,
complist.Amount - complist.Used - ISNULL(complist.Correction,0)
FROM
complist, componenttrace
WHERE
complist.McID = 1004
AND complist.CompID = componenttrace.CompID
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
ORDER BY
complist.CompName, complist.CompID
On the application, the part that goes
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
is added automatically if there's any value on a given field (i.e. 1.1
).
I have a SQL syntax problem, but don't know how to solve it. Can anyone shed some light here?
thanks,
Gustavo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有错误消息,很难说出了什么问题,但我的赌注是隐式连接。尝试
Without error message is very hard to say what is wrong, but my bet is on the implicit join. Try