我有以下带有 SQL 查询的代码PreparedSentence:
public final ProductInfoExt getProductInfoByCode(String sCode, String siteGuid) throws BasicException {
if (sCode.startsWith("977")) {
// This is an ISSN barcode (news and magazines)
// the first 3 digits correspond to the 977 prefix assigned to serial publications,
// the next 7 digits correspond to the ISSN of the publication
// Anything after that is publisher dependant - we strip everything after
// the 10th character
sCode = sCode.substring(0, 10);
}
return (ProductInfoExt) new PreparedSentence(s, "SELECT "
+ getSelectFieldList()
+ " FROM STOCKCURRENT AS C RIGHT JOIN PRODUCTS P ON (C.PRODUCT = P.ID) "
+ " WHERE P.CODE OR (P.REFERENCE = ? ) AND C.SITEGUID = ? ",
new SerializerWriteBasicExt(new Datas[]{Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING}, new int[]{0, 1}),
ProductInfoExt.getSerializerRead()).find(sCode, siteGuid);
}
P.CODE如果我通过:进行搜索,效果会很好WHERE P.CODE = ? AND C.SITEGUID = ?。P.REFERENCE但是,假设我希望它在if 中没有匹配的情况下找到结果P.CODE。我尝试执行这样的代码语句,但没有成功:WHERE P.CODE OR P.REFERENCE = ? AND C.SITEGUID = ?,但收到错误。任何帮助将不胜感激。
扬帆大鱼
繁星coding
相关分类