conditional

Conditional JOIN different tables

大城市里の小女人 提交于 2020-01-28 04:07:53
问题 I want to know if a user has an entry in any of 2 related tables. Tables USER (user_id) EMPLOYEE (id, user_id) STUDENT (id, user_id) A User may have an employee and/or student entry. How can I get that info in one query? I tried: select * from [user] u inner join employee e on e.user_id = case when e.user_id is not NULL then u.user_id else null end inner join student s on s.user_id = case when s.user_id is not NULL then u.user_id else null end But it will return only users with entries in

Conditional JOIN different tables

只愿长相守 提交于 2020-01-28 04:07:08
问题 I want to know if a user has an entry in any of 2 related tables. Tables USER (user_id) EMPLOYEE (id, user_id) STUDENT (id, user_id) A User may have an employee and/or student entry. How can I get that info in one query? I tried: select * from [user] u inner join employee e on e.user_id = case when e.user_id is not NULL then u.user_id else null end inner join student s on s.user_id = case when s.user_id is not NULL then u.user_id else null end But it will return only users with entries in

Python 3 automatic conditional import?

梦想的初衷 提交于 2020-01-26 01:00:25
问题 Is there any nice way to import different modules based on some variable value? My example: I have a folder with different modules: module_a.py module_b.py And in some other python file i want to import either module_a or module_b based on some config value: if configVal == 'a': import module_a elif configVal == 'b': import module_b Is there some way to avoid using if-elifs? So somehow automatically? like: @conditionalImport(configVal) import module_ Or something clever? 回答1: You can use the

Python 3 automatic conditional import?

喜夏-厌秋 提交于 2020-01-26 00:58:13
问题 Is there any nice way to import different modules based on some variable value? My example: I have a folder with different modules: module_a.py module_b.py And in some other python file i want to import either module_a or module_b based on some config value: if configVal == 'a': import module_a elif configVal == 'b': import module_b Is there some way to avoid using if-elifs? So somehow automatically? like: @conditionalImport(configVal) import module_ Or something clever? 回答1: You can use the

Regex to accept 3 out of 4 rules

狂风中的少年 提交于 2020-01-24 09:54:12
问题 I can't seem to get the regex correct for the following requirement: a string between 8 and 20 length that must contain at least 1 uppercase alphabet character, at least 1 lowercase alphabet character, and either at least 1 digit or at least 1 special character (or both). Let's say special characters are restricted to include just @,#,&,~. I wrote this initially: ^(?=.*?[A-Z])(?=.*?[a-z])(?=(.*?[0-9])|(.*?[@#&~])).{8,20}$ So as expected it successfully matches strings like 5abcdefG, Abc

how to change xml by browser

北城余情 提交于 2020-01-23 18:03:44
问题 I would like to change some rules in my XML depending on the browser. For example, the 'fontcolor' should be black when using IE. So far I googled it, I found this could be possible using XSLT. But unfortunately, after googling/trying&error after 1/2 days, I still didn't get the clue how to do this. Could someone help me how to solve this? Any help would be highly appreciated. Thanks !! EetieD. My current XML: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href=

how to change xml by browser

匆匆过客 提交于 2020-01-23 18:03:33
问题 I would like to change some rules in my XML depending on the browser. For example, the 'fontcolor' should be black when using IE. So far I googled it, I found this could be possible using XSLT. But unfortunately, after googling/trying&error after 1/2 days, I still didn't get the clue how to do this. Could someone help me how to solve this? Any help would be highly appreciated. Thanks !! EetieD. My current XML: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href=

R - Assign a value/factor in a data.frame to column conditioned on value(s) of other columns

别来无恙 提交于 2020-01-23 16:20:50
问题 set.seed(8) df <- data.frame(n = rnorm(5,1), m = rnorm(5,0), l = factor(LETTERS[1:5])) Have can I make a new column in df conditioned on values or combination of values of n, m and l. For instance make a vector level and assign it low , medium and high based on values of both n and m (pseudo-code): df$level <- ifelse(df$n < 1 & df$m < 1, "low", ifelse(df$n > 1 & df$m > 1, "high", "medium") This should give: df$level #low medium low low medium Or if I would like to assign a value to level

R - Assign a value/factor in a data.frame to column conditioned on value(s) of other columns

折月煮酒 提交于 2020-01-23 16:20:27
问题 set.seed(8) df <- data.frame(n = rnorm(5,1), m = rnorm(5,0), l = factor(LETTERS[1:5])) Have can I make a new column in df conditioned on values or combination of values of n, m and l. For instance make a vector level and assign it low , medium and high based on values of both n and m (pseudo-code): df$level <- ifelse(df$n < 1 & df$m < 1, "low", ifelse(df$n > 1 & df$m > 1, "high", "medium") This should give: df$level #low medium low low medium Or if I would like to assign a value to level

automake Environment Variable Condition

家住魔仙堡 提交于 2020-01-23 13:34:31
问题 I have a file Makefile.am I am using to generate a Makefile. In the generated Makefile I want to have something like: ifndef SOURCECODEPATH SOURCECODEPATH := /home/root/source_code_path endif It seems so simple, does anyone know how I can do it? 回答1: Use the AM_CONDITIONAL macro in configure.ac . The script sets a variable you can test, e.g., a variable that is set to non-empty if the condition is enabled: AM_CONDITIONAL([ENABLE_SOURCECODEPATH], [test "x$ac_srcpath" != "x"]) Then in Makefile