搜索产品列表时,@SearchType
参数是可选的.如果@SearchType
是空的,NULL
那么它应该返回所有产品而不使用该WHERE
子句.否则,如果它通过Equipment
它然后将使用它.
ALTER PROCEDURE [dbo].[psProducts]
(@SearchType varchar(50))
AS
BEGIN
SET NOCOUNT ON;
SELECT
P.[ProductId],
P.[ProductName],
P.[ProductPrice],
P.[Type]
FROM [Product] P
-- if @Searchtype is not null then use the where clause
WHERE p.[Type] = @SearchType
END
Run Code Online (Sandbox Code Playgroud) 我需要拆分关键字字符串并将其转换为逗号分隔的字符串.但是,我需要摆脱额外的空格和用户已经输入的任何逗号.
var keywordString = "ford tempo, with,,, sunroof";
Run Code Online (Sandbox Code Playgroud)
输出到此字符串:
ford,tempo,with,sunroof,
Run Code Online (Sandbox Code Playgroud)
我需要尾随逗号,最终输出中没有空格.
不确定我是否应该使用Regex或字符串拆分功能.
有人做过这样的事吗?
我需要使用javascript(或JQ).
编辑(工作解决方案):
var keywordString = ", ,, ford, tempo, with,,, sunroof,, ,";
//remove all commas; remove preceeding and trailing spaces; replace spaces with comma
str1 = keywordString.replace(/,/g , '').replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace(/[\s,]+/g, ',');
//add a comma at the end
str1 = str1 + ',';
console.log(str1);
Run Code Online (Sandbox Code Playgroud) 我应该如何设置访客结帐转换渠道?
我需要设置访客与注册用户渠道来分别跟踪转化情况.具体来说,我们需要查看目标完成(转换),购物车放弃,退回,退出,因为我们A/B不同的页面视图(更改中间页面上的UI).
问题:
1)正则表达式似乎不适用于客户漏斗可视化.谷歌在可视化漏斗中报告了0个会话,尽管它显示0.8%的访问完成了这一目标.
2)理想情况下,我不想用查询字符串参数标记每个客户页面.
典型流程如下:购物车>登录>送货>送货>付款>审核>完成
我从Shipping开始,因为这是guest用户的fork(我们添加querystring参数).
访客目标目标
Regular Expression: ^\/complete\?guest=.*$
Step 1: /shipping?guest=1 (REQUIRED)
Step 2: /delivery
Step 3: /payment
Step 4: /review
Step 5: /complete?guest=1 (Destination)
Run Code Online (Sandbox Code Playgroud)
注册用户目的地目标
Regular Expression: ^/complete$
Step 1: /shipping (REQUIRED)
Step 2: /delivery
Step 3: /payment
Step 4: /review
Step 5: /complete (Destination)
Run Code Online (Sandbox Code Playgroud)
注册用户目标正则表达式正在运行,感谢Allen,但是客户目标仍未按预期工作.
我试过这些正则表达式:
^\/complete\?guest=.*$
\/complete\?guest=.*$
/complete\?guest=.*$
/complete\?guest=1
/complete/?guest=1
Run Code Online (Sandbox Code Playgroud)
Google表示,此目标已在0个会话中完成
然而,它显示目标的目标转换率为0.8%.我的理解是,这是因为Google只评估最后一个匹配的URL.但是,对于会话转换,正则表达式必须应用于渠道中的所有页面,以便可视化列出会话编号.
编辑:
如果有人发现它有用,这是完整的工作示例.诀窍是这些步骤还需要正则表达式语法并从步骤中取出最终目标.
访客目标目标
Regular Expression: /complete\?guest=1$
Step 1: /shipping\?guest=1 (REQUIRED)
Step 2: /delivery
Step 3: /payment
Step 4: /review …
Run Code Online (Sandbox Code Playgroud) 如何使用Linq或EF Join之类的东西在C#MVC中实现连接和位置?
这是我试图实现的等效SQL.
select * from promotion P
JOIN PromotionsClaimed PC
on PC.PromotionId = P.objectid
where PC.userId = @USERID
Run Code Online (Sandbox Code Playgroud)
此方法应返回用户的促销列表.首先,我获得所有促销的列表,然后我获得用户声明的促销的综合列表.这就是我到目前为止所拥有的.
public IList<Promotion> GetRewardsForUser(string userId)
{
//a list of all available promotions
IList<Promotion> promos = _promotionLogic.Retrieve();
//contains a list of Promotion.objectIds for that user
IList<PromotionsClaimed> promosClaimed = _promotionsClaimedLogic.RetrieveByCriteria(t => t.userId == userId);
//should return a list of the Promotion name and code for the rewards claimed by user, but a complete list of Promotion entities would be fine
var selectedPromos = …
Run Code Online (Sandbox Code Playgroud) 检查和取消选中(选择并取消选择全部)复选框列表时遇到两个问题:
例:
http://jsfiddle.net/TheFiddler/v6wmV/ ,
$(document).ready(function(){
$('.all').toggle(
function() {
$('.check').find('input[type=checkbox]').attr('checked', true);
},
function() {
$('.check').find('input[type=checkbox]').attr('checked', false);
});
});
Run Code Online (Sandbox Code Playgroud)
现在,我在一个类上有事件,因为这个类由两个复选框列表共享,所以它们都会切换.
我无法使用1.7获取新的.on点击工作.
对于动态创建的链接(例如通过单击"创建"按钮生成的链接),这些链接需要与DOM中的静态链接相同的单击功能.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript">
function createDivs(){
content = '<div class="tile-button"><a class="tile-action" href="#" rel="1234" alt="Open">Dynamic Link</a></div>';
$(content).appendTo("#dynamicArea");
$('.tile-action').bind('click',function(){});
}
$(document).ready(function(){
$('#createButton').on("click", createDivs);
$('#destroyButton').on("click", function(event){
$("#dynamicArea").html("");
});
$('.tile-action').on("click", function(event){
var linkalt = $(this).attr("alt");
var linkrel = $(this).attr("rel");
alert(linkalt + " " + linkrel);
return false;
});
});
</script>
</head>
<body>
<button id="createButton">CREATE</button> <button id="destroyButton">Destroy :(</button>
<div id="dynamicArea"></div>
<br>
<a class="tile-action" href="#" rel="1234" alt="Open">Link</a><!-- works -->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在此问题的简化示例中,单击"创建"按钮时,将显示动态链接.当您单击没有任何反应时,这些动态链接不像静态链接那样调用警报.
我有一张表,其中包含旧的遗留数据和新数据.旧数据没有像新数据那样填充所有字段.我想更新旧数据,以便与新内容匹配.这些字段是整数并表示用户ID.Created_By字段应默认为User_ID - 这意味着在旧数据中,我们将created_by值设置为与user_id相同.
示例字段:
Created_By | User_ID
NULL | 1234
NULL | 2345
NULL | 1234
NULL | 6742
1234 | 1234
2345 | 1234
Run Code Online (Sandbox Code Playgroud)
所以我想只更新NULL值.但是,我不知道如何获取每一行的User_ID.
像这样的东西:
update my_table
set Created_By = ??? (the respective User_ID for that row)
where Created_By is null
Run Code Online (Sandbox Code Playgroud)
因此更新应如下所示:
Created_By | User_ID
1234 | 1234
2345 | 2345
1234 | 1234
6742 | 6742
1234 | 1234
2345 | 1234
Run Code Online (Sandbox Code Playgroud) jquery ×2
sql ×2
bind ×1
c# ×1
checkbox ×1
click ×1
field ×1
if-statement ×1
javascript ×1
linq ×1
regex ×1
replace ×1
split ×1
sql-server ×1
string ×1
toggle ×1
trim ×1
where-clause ×1