尝试创建一个存储过程,我可以使用它来按名字和姓氏搜索人员。 Fname和Lname一起存储在两个不同的表中,希望从_saveOptions = [[IKSaveOptions alloc] initWithImageProperties: _imageProperties
imageUTType:(NSString*)kUTTypeJPEG];
拉出来,如果没有匹配,则从Table1
拉出结果。
Table2
到目前为止我尝试的是这个,它似乎拉回了所有的记录。
@FName VARCHAR(20) = NULL
@LName VARCHAR(20) = NULL,
SELECT TB1.ID, TB1.FName, TB1.LName
FROM Table1 TB1
LEFT JOIN Table2 TB2
ON TB1.ID = TB2.ID
WHERE 1=1
AND COALESCE(TB1.Fname, '') LIKE '%' + REPLACE(COALESCE(@FName, TB1.Fname, ''), ' ', '%') + '%'
AND COALESCE(TB1.Fname, '') LIKE '%' + REPLACE(COALESCE(@LName, TB1.Fname, ''), ' ', '%') + '%'
任何帮助或指导都会感激不尽,我在最后一天左右谷歌,但我想我正在谷歌搜索错误的东西。
答案 0 :(得分:2)
您应该使用完全加入,确保您合并结果,以便从任何具有数据的表中提取结果。
SELECT Coalesce(TB1.ID, TB2.ID) As ID,
Coalesce(TB1.FName, TB2.FName) As FName,
Coalesce(TB1.LName,TB2.LName) As LName
FROM Table1 TB1
Full JOIN Table2 TB2
ON TB1.ID = TB2.ID
答案 1 :(得分:1)
在玩了一会儿并看着G Mastros发布的内容之后,它让我想到了当我真正需要的只是一个时,我试图调用两个django.contrib.admin.FieldListFilter
语句。所以我稍微更改了set.seed(107)
library(fpp)
library(rgenoud)
adstock_k <- function(x, adstock_rate = 0, max_memory = 12){
learn_rates <- rep(adstock_rate, max_memory+1) ^ c(0:max_memory)
adstocked_advertising <- stats::filter(c(rep(0, max_memory), x), learn_rates, method="convolution")
adstocked_advertising <- adstocked_advertising[!is.na(adstocked_advertising)]
return(as.numeric(adstocked_advertising))
}
getRMSE <- function(x, y) {
mean((x-y)^2) %>% sqrt
}
df <- data.frame(insurance) %>%
mutate(Quotes = round (Quotes*1000, digits = 0 ))
df$idu <- as.numeric(rownames(df))
my_f <- function(xx){
adstock_rate <- xx[1]
adstock_memory <- xx[2]
df.temp <- df %>%
mutate(adstock = adstock_k(TV.advert, adstock_rate/100, adstock_memory ))
mod <- lm(data=df.temp, Quotes ~ adstock )
getRMSE( df.temp$Quotes, predict(mod))
}
domaine <- cbind(c(30,1), c(85, 8))
#this works
min_f <- genoud(my_f, nvars = 2, max = F, pop.size=1000, wait.generations=10, Domains = domaine, data.type.int = T)
#here I try to add a second parameter to the function.
my_f2 <- function(xx,first_n_weeks=20){
adstock_rate <- xx[1]
adstock_memory <- xx[2]
df.temp <- df %>%
filter(idu<= first_n_weeks) %>%
mutate(adstock = adstock_k(TV.advert, adstock_rate/100, adstock_memory ))
mod <- lm(data=df.temp, Quotes ~ adstock )
getRMSE( df.temp$Quotes, predict(mod))
}
#this doesnt work
min_f2 <- genoud(my_f2(first_n_week=10), nvars = 2, max = F, pop.size=1000, wait.generations=10, Domains = domaine, data.type.int = T)
语句并将它们放在一个OR
中,这反过来又给了我所需的结果。
我觉得这是一个可以根据需要添加其他请求的工作,所以例如我需要根据电子邮件或电话号码进行搜索。
COLESCE