如何在字段中使用单引号在Sql查询中的Where子句中使用 [英] How Do I Use Single Quote In The Field To Be Used In Where Clause In Sql Query
本文介绍了如何在字段中使用单引号在Sql查询中的Where子句中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在创建一个简单的SQl服务器加入命令。问题是要加入的字段将包含单引号组成的字符串,该字符串不起作用。
另外,如何使用2个条件来连接2个表。
这里,字段bom.bommn是字符串,可能包含单引号或双引号。
Hi All,
I am creating a simple SQl server Join command. The problem is that the field to join will have string also consisting of single quotes which is not working.
Also, how can I use 2 criteria for Join of 2 tables.
Here, the field bom.bommn is string which may contain single quotes or double quotes.
Select PBOMS,PBOMM,PBOMTAG,PBOMMT,PBOMQ as NewQty,PBOMU,BOM.BOMIQ AS StdQty
FROM PBOM LEFT JOIN BOM ON (PBOM.PBOMM = BOM.BOMMN and PBOM.PBOMMT=BOM.BOMIN) where
PBOMPC=@PBOMPC AND PBOMG=@PBOMG and PBOMETY<>@PBOMETY AND PBOMS LIKE @PBOMS
AND PBOMM LIKE @PBOMM AND PBOMTAG LIKE @PBOMTAG
推荐答案
全部谢谢。发现问题。在一个表中,用户输入了两次单引号,而在另一个表中,不同的用户输入了双引号。
Thanks all. Problem found. In one table the user has entered single quotes twice and in the other the different user has entered double quotes.
这篇关于如何在字段中使用单引号在Sql查询中的Where子句中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文