简体   繁体   English

在水晶报表中的参数中使用SQL like运算符

[英]Using SQL like operator within a parameter in crystal report

I need to use a like wildcard in the sql code for one of the paramenters in the crystal report. 我需要在sql代码中使用类似通配符的晶体报告中的一个参数。

I'm looking at stock symbols in SQL Server, my code works if I'm looking for the exact symbol but I need to search for similar symbols to catch any options or other versions of the stock. 我正在查看SQL Server中的股票代码,如果我正在寻找确切的符号,我的代码可以工作,但我需要搜索类似的符号来捕获任何选项或其他版本的股票。 ie not just GOOG, but like '%GOOG%'. 即不仅仅是GOOG,而是像'%GOOG%'。 I can't find much online but I've tried using * instead of % and played around with the format but if I put in anything other than the exact symbol, my report comes up blank. 我在网上找不到多少,但我尝试使用*代替%并使用格式,但如果我输入除了确切符号以外的任何内容,我的报告就会显示为空白。

Original code: 原始代码:

where SYMB like '%GOOG%' 

Crystal code: 水晶代码:

where SYMB like {?symbol}

-----this will work but only if I type in the exact symbol that shows up, no deviations---- -----这样可以工作,但只有输入显示的确切符号,没有偏差----

I tried adding ' "& {?symbol} & ' ' - that didn't work either 我尝试添加' “&{?symbol}&' ' - 这也不起作用

When I run the code in sql server I get several lines that spit out trades for an option on GOOG, something like 'GOOG 160215C1200' but running the code through crystal spits out nothing because it is ONLY looking for 'GOOG' specifically. 当我在sql server中运行代码时,我会得到几行代码来解决GOOG上的一个选项,比如'GOOG 160215C1200',但通过水晶吐出的代码没有任何东西,因为它只是专门寻找'GOOG'。

Try doing it this way: 尝试这样做:

SYMB like ["*GOOG*"] // will return values containing GOOG ["*GOOG*"] //的SYMB将返回包含GOOG的值

OR 要么

SYMB like "*" & {?GOOG} & "*" SYMB如"*" & {?GOOG} & "*"

Try this way: 试试这种方式:

{SYMB} like {?sample}

this {SYMB} must be your field without parenthesis like SYMB cannot be. 这个{SYMB}必须是没有括号的字段,如SYMB所不能的。

For crystal syntax 对于水晶语法

SYMB like '*' + {?symbol} + '*'

If it is in the WHERE clause in a SQL command used for selecting data within Crystal then 如果它位于用于在Crystal中选择数据的SQL命令的WHERE子句中

WHERE SYMB LIKE '%' + {?symbol} + '%'

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

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