FAQ Database Discussion Community


How to filter table with conditions stored as parameters in another table?

sql,sql-server,parameters,filter,condition
I want to use parameters stored in tableA to filter tableB. Here is my tableA with parameters: I want to filter tableB with more or less such a query: WITH A AS (SELECT [FilterType] ,[MaxID] FROM TableA WHERE [FilterType]=1 ) SELECT * FROM TableB B WHERE B.ID>A.MaxID I want to...

MySQL SELECT email where field contains a value

mysql,sql,condition
I would like to do a simple select - but the condition is a bit tricky for me (because I'm a SQL-beginner). I got this table: userid | email | newsletters 1 | [email protected] | 1,2 2 | [email protected] | 1 Now I would like to get all email-addresses of...

Check the conditions every time after function has been called

javascript,function,condition
I have written a function show() - which reveals hidden id classes (I know there is jquery and other methods to do it, but I wanted it this way). //------------------------- // Function show() //------------------------- /** * Changes element class name from hide to show in parent element [ default: content...

counting unique values with it's associated count and total number of values

javascript,jquery,loops,condition
It may be simple but I am struck now. I have an array items=["shelter","tent","shelter","injured","displaced","displaced"] and it's values with it's respective value as magnitude = [5,12,6,9,13,2] Now,the task is to add item_name with it's respective total magnitude and number of its occurrence as: shelter for 11 people, tent for 12 people,...

PHP condition with IF working incorrect [duplicate]

php,if-statement,upload,condition
This question already has an answer here: Check if string contains specific words? 25 answers I have the following code, and when I upload a file with named "abc.htaccess" then it works correctly by showing "attacked", but when I upload abc.php or abcphp file name, then it tell me...

Select from table where some WHERE condition missing

php,mysql,sql,sorting,condition
I have following sql request if(isset($_GET['room'])) { if($_GET['status'] == 'all' && $_GET['room'] == 'all'){ $stmt = $pdo->prepare("SELECT DISTINCT flatnetto FROM flat ORDER BY flatnetto"); $stmt->execute(array($_GET['room'], $_GET['status'])); }else if($_GET['status'] == 'all'){ $stmt = $pdo->prepare("SELECT DISTINCT flatnetto FROM flat WHERE kk = ? ORDER BY flatnetto"); $stmt->execute(array($_GET['room'])); }else if($_GET['room'] == 'all'){ $stmt...

Python, appending to a list using conditions

python,list,condition
I have a file with two columns, lets say A and B A B 1 10 0 11 0 12 0 15 1 90 0 41 I want to create a new column (a list), lets call the empty list C = [] I would like to loop through A,...

How to set the condition in my if statement, if the user has to type in a whole number? C# [closed]

c#,if-statement,condition
//Hold the Roses' cost decimal numberofRoses;//user's desired number of roses decimal totalCostofRoses; //the total amount of the roses' price const decimal COST_PER_ROSE = 10;//each rose cost 10 dollars //Get the user's input numberofRoses = decimal.Parse(rosesTextBox.Text); if ()//Require a condition where the user has to type in a whole number {...

MySQL Query with Inner Join and multiple conditions

php,mysql,select,condition
I am having trouble working out how to user Inner Join correctly and targeting other tables for multiple conditions within one MySQL query. Basically, I am creating a small follower feed for my Website, which outputs new posts from any user that you are following. Posts Table: id | user_id...

Conditional execution of resources

chef,condition,chain
I have the following 2 resources defined within a cookbook that makes HTTP requests. I essentially need to execute action 2 based on checking a condition from the result of action 1. If the condition from action 1 does not match I need the cookbook to sleep for a period...

Python Pandas: How to use 'where' and 'isin' with two conditions?

python,pandas,group-by,condition
I have a dataframe 'dfm' : match_x org_o group match_y 0 012 012 Smile Communications 92 012 1 012 012 Smile 92 000 2 10types 10TYPES 93 10types 3 10types 10types.com 97 10types 4 360works 360WORKS 94 360works 5 360works 360works.com 94 360works I would like a column to 'a'...

Condition for clicking on canvas shapes?

javascript,canvas,condition
I don't why in else section my condition is false this is my code address: I don't know this condition isn't work correctly(line 49 in js section)? fiddle <div id="ways" style="width:1000px;margin:0 auto;height:100%;"> <canvas id="canvas" width="1000" height="1000"></canvas> </div> ...

Assing to data.frame bases on a vector value leaving the rest untouched

r,data.frame,condition
Thanks for your time here. I have this old code in FORTRAN that I was asked to convert to R. Involves a bunch of lines, all within a while loop and in there I have some calculations I need to perform on the data structures based in a condition vector,...

How to check user entered date is greater than 32 days from current date in java

java,validation,date,condition,jodatime
I would like to validate the date input of the user based on a condition. The condition is new date entered by user should be greater than 32 days. How to do the same?. I have tried the following but it is not working. final Date getuserDate = validate.date(); logger.debug("UserDate...

Selection Condition Array In PHP

php,arrays,if-statement,conditional,condition
i have PHP code with loop: $explodeResult=explode(", ",$serviceName); foreach($explodeResult as $value) { $sql = "SELECT id,parent,code,name,xs1 as DOWNLOAD, xs2 as UPLOAD FROM sc_params WHERE rfen = 'SERVICE_REQUESTED' AND code = :param1 OR code IN ( SELECT code FROM sc_params WHERE rfen = 'SERVICE_REQUESTED' AND id = ( SELECT parent FROM...

How To Convert Array To XML With Condition On PHP

php,arrays,xml,condition
i have PHP code like this: public function get_xml_product($serviceName) { $product = Array(); $idx = $idx2 = 0; $explodeResult=explode(", ",$serviceName); foreach($explodeResult as $value) { $sql = "SELECT id,parent,code,name,xs1 as DOWNLOAD, xs2 as UPLOAD FROM sc_params WHERE rfen = 'SERVICE_REQUESTED' AND code = '".$value."' OR code IN ( SELECT code FROM...

How many conditions can an if check for

java,if-statement,condition
How many conditions can an if check for? EG, if(a==1 && b==1 && c==1 && ... && n==1) I know this could probably be solved simply by nesting ifs and then it wouldn't be an issue how many. But frankly, I'm curious and can't seem to find how many it...

MySQL Conditional count based on a value in another column

mysql,count,distinct,condition
I have table that looks like this: id rank a 2 a 1 b 4 b 3 c 7 d 1 d 1 e 9 I need to get all the distinct rank values on one column and count of all the unique id's that have reached equal or higher...

Can I assume NULL value in comparison as the false?

c,pointers,comparison,condition,null-pointer
I know that NULL == (void *)0 but it is mentioned that it can be represented as a value which doesn't contain all zeros. What bothers me is if those pieces of code are equivalent for all (any_type *): any_type *val; if (val) { ... }; and if (val !=...

How do you start a function at a certain time in Python?

python,multithreading,events,time,condition
I have a list of timestamps, and I need to call a specific method when those timestamps are reached. Those timestamps are roughly 20ms apart. At the moment I am using busy waiting in a separate thread, but I am worried about the CPU overload. Example : while True: if...

How to create a new variable with values from different variables if another variable equals a set value in R?

r,conditional,condition,subset
I have a complicated question that I will try to simplify by simplifying my dataset. Say I have 5 variables: df$Id <- c(1:12) df$Date <- c(NA,NA,a,a,b,NA,NA,b,c,c,b,a) df$va <- c(1.1, 1.4, 2.5, ...) #12 randoms values df$vb <- c(5.9, 2.3, 4.7, ...) #12 other random values df$vc <- c(3.0, 3.3, 3.7,...

T-SQL conditional AND statement

sql-server,tsql,condition,table-valued-parameters,sql-in
I'm trying to set up a stored procedure where I'm taking in a table value parameter and using it inside an IN statement to grab the results, the issue is the table value parameter can be empty, is there a way for me to conditionally insert an entire and statement?...

typoscript condition on get parameter

parameters,get,condition,typoscript
I'm trying to include separate setup.ts files, based on a "custom" GET parameter, but no matter I give ?custom=1 or not, the code always enters the ELSE clause and I get "bbb" on top of the page. Where am I wrong? [globalVar = GP:custom = 1] <INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/templates/typoscript/CUSTOM/setup.ts"> page.1 =...

How to use AND operator for comparison in javascript?

javascript,html,string,if-statement,condition
I am trying to use AND condition to compare two conditions inside an if block. I am getting the website address using window.location.href function and then i am tring to compare them using match function. I am not able to figure out way i am not getting the desired result....

Communication between threads in Java without lock

java,multithreading,condition,reentrantlock
So what i want to achieve is two threads taking turn in executing their task. I originally had just one question; How can i achieve two threads taking turns in executing their task without using a lock? Reason why i don't want the lock is because I'm feeling stupid, using...

Python Reuse a Variable in the Else Block of an If-Else Statement

python,python-3.x,if-statement,condition
I'm currently working on a simple file transfer program in Python. I am having trouble with the function for prompting the user for the location of the folder to be copied. def getSrc(): if getSrc.has_been_called is False: source = askdirectory() getSrc.has_been_called = True return source else: return source getSrc.has_been_called =...

C++: Checking if user input is one of the characters A, W, or D

python,c++,validation,loops,condition
In Python I can do: char_choice = input("What is your character choice? Please enter A, W or D.") while char_choice.lower() not in ["a", "w", "d"]: char_choice = input("You entered an incorrect character. Please try again:") Is there a way I can repeat line 2 in C++? I have tried the...

C conditional increment

c,condition,increment,temporary
Consider the following code: int a=0 , b=1 If (a == --b) Printf b Is b now 0 or 1? In other words- is the increment temporary or not? Thank you!...

Matching a pattern with `match()` with extra condition

r,match,condition
Expanding on a previous question (R: gsub of exact full string with fixed = T). [With huge thanks to everyone who helped there. Special thanks to @MrFlick] I need to change "32 oz" to "32 ct" but only if extra condition "3" is met, not in any other case. exact_orig...

LINQ to SQL: How to create something like conditional include?

.net,linq,entity-framework,include,condition
I'd like to create a query contains User whose entities has Event with type == 1. I would also like the Event entries loaded into EventsCollection. My code would be something like .Include(u => u.EventsCollection), but this only loads all Event entries - I want to load only with type...

if condition always returns true (Java)

java,date,if-statement,condition
I am trying to implement a date system that inevitably displays tomorrows day, month and year. The problem I am having is that the one of the if statements always returns true, and the ones after this one always return false. Here is part of my code: public class dateVerification...

WIX. How to not reinstall a feature during repair?

wix,condition,reinstall
In WIX I'd like a feature to be installed and uninstalled normally but not to be touched during repair. I was not able to find a condition which would allow me to do this. My attempts has failed: the feature is reinstalled on repair (what I do not need) or...

VBA lookup for approximate value

vba,match,condition,criteria,vlookup
I want to perform a special VLookup where the value which is found would match two conditions: The invoice number must be the same The value found from Column G must be within the tolerance -100 to 100 Precisely speaking, if the first value found from Column G (e.g. -18,007)...

ruby // present or nil

ruby,syntax,condition
Simple example : val = (params[:page] ? params[:page] : nil) I just don't know how to name it, then can't find an better answer for it I feel like a simpler syntax exists for this example; and would like to know how to write it better...

Matlab: using a string as condition for if statement

string,matlab,if-statement,condition
cond = 'a==1'; a=1; if (cond) b=0; end Hi! Is there a way to do the thing I wrote above? In a text variable I need to write a condition (even a complex one, using && and || too) and then in the IF statement I simply insert the variable....

Excel IF AND OR condition together

excel,if-statement,condition
I am trying to use this formula in excel but am getting an error. Can someone please help? =IF(OR(AND(B2>=Sheet3!$B$4,B2<=Sheet3!$C$4),AND(B2>=Sheet3!B6,B2<=Sheet3!C6))),"Blue","Grey") Programmatically, I am trying to get this: If((a>x && a<y) || (a>x1 && a<y1)){ Blue } else { Grey } ...

how to calculate the mean with conditions? [duplicate]

r,condition,mean
This question already has an answer here: Calculating mean when 2 conditions need met in R 2 answers Below is the script to generate a reproducible dataframe: id <- c(1:20) a <- as.numeric(round(runif(20,-40,40),2)) b <- as.numeric(round(a*1.4+60,2)) df <- as.data.frame(cbind(id, a, b)) i would like to calculate the mean of...

R sorting using simple codes

r,sorting,date,condition
Can someone help me with the below problem? Dataset sample: Ticketid Creation_Date Location Person a1 01-02-2015 A John b1 03-02-2015 B Jack c1 03-02-2015 C Mint a1 03-02-2015 D Manu d1 03-02-2015 A Somu e1 03-02-2015 A John b1 11-02-2015 B Jack a1 11-02-2015 C Mint b1 14-02-2015 F John...

How to remove all empty tag with conditons in XSL

xml,xslt,tags,condition,xmlns
I want to remove empty tags with exception. I made an XSL to remove all empty tags with exception. Following the XSL below: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*"/> <xsl:preserve-space elements="cEAN"/ priority="1"> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="*[not(@*) and not(*) and...

Hibernate HQL query with condition on second table

oracle,hibernate,hql,condition,one-to-many
I have two tables (about football): Leagues and Teams which are in one-to-many relation. Now I want to get ALL Leagues but only with those teams which names start e.g. with "S". So far I have this: Query query = session.createQuery("select l from League l left join l.teams as t...

preg_match only show replacement if found

php,regex,condition
The title must be very confusing, but I have to admit, so am I when it comes to regex. My problem is the following: I have an input string like: {a href=www.google.com}Google{/a} {b}boldText{/b} What I want to achieve is following: <a href="www.google.com">Google</a> <b>boldText</b> I have the following preg_replace function: $input...

How to use objects within if statements - Javascript

javascript,arrays,condition
At present I have a list of conditional statements such as: if(x = 1) { $(#div).html('A') }; if(x = 2) { $(#div).html('B') }; if(x = 3) { $(#div).html('C') }; if(x = 4) { $(#div).html('D') }; This does the job but isn't very efficient. I'm trying to take a DRY approach...

Triple Conditioned selection of data in r

r,selection,condition
I am expanding a question asked 5 months ago: Double Conditioned selection of data in r I need to add a condition now and I cannot do it on the suggested solution. Apparentely my coding skill have not improved much :/ reproducible example: time.stamp <- c(1:22) behavior <- c("close", "1","2","1","1",...

How to order SQL query result on condition?

sql,postgresql,order,condition
i have the this SQL query: SELECT DISTINCT category FROM merchant ORDER BY category ASC that gives this output: accommodation education food general health money shopping sport transport How to put the row that contains "general" at the start (or the end) of the result?...

java code: if statement not the expected output [duplicate]

java,if-statement,condition
This question already has an answer here: Division of integers in Java 4 answers The output should be the salary + rise 4% or 6%. This is my code: int x = input.nextInt(); //x 1,2 or3// System.out.println("enter the sallary:"); int y = input.nextInt(); // salary// if (x == 1)...

How to implement a search in multiple fields based on condition(s)

java,hibernate,if-statement,condition,hibernate-criteria
I am trying to implement a Hibernate Full Text Search. The user can choose, which fields are relevant for the search or not. This is done by six (my example) boolean checkboxes in JSF. Six booleans mean 2^6 possible combinations. I need to map all those conditions. Example: boolean a;...

Parse error: syntax error, unexpected 'if' (T_IF), expecting ')'

php,arrays,if-statement,condition
How can I add a condition inside a php array? Here is the array $content['custom_fields'] = array( array( "key" => "_yoast_wpseo_focuskw", "value" => $_POST["title"] ), array( "key" => "_yoast_wpseo_metadesc", "value" => $_POST["titleenfa"] ), array( "key" => "_yoast_wpseo_metakeywords", "value" => $_POST["metakey"] ), if($_POST["link128"]){ array( "key" => "_link128", "value" => "field_54b398292c295" ),...

Regexp split string with additional conditions

python,regex,split,condition
I have string like a = 'text1, text2 (subtext1, subtext2), text3' Need split that string on parts by comma-symbols, but only those that are not in the frame brackets: splited = ['text1', 'text2 (subtext1, subtext2)', 'text3'] How make that with regular expression?...

Classic ASP Vbscript Conditional Statement for Time() not giving correct results

time,vbscript,asp-classic,condition
im working on a simple Conditional statement in vbscript to check whether a time is earlier than another time. and its not working or making any sense. just using dates seem to work but i need to use time... which isnt working. dim startDateStartTime, CurrentDateCurrentTime startDateStartTime = FormatDateTime("12:00:00 PM") response.Write("The...

Wix: Run custom action based on condition

wix,windows-installer,conditional,condition,custom-action
I'm trying to run a custom action (delete a certain file) based on the windows version. I know how to check for the windows version: <Condition Message="Windows version xxx required..."> <![CDATA[Installed OR (VersionNT >= 600)]]> </Condition> However, I do not want to display a message, but delete a file. I...

How to autowire properties bean from Condition

java,spring,initialization,condition,autowired
Does have anyone way to autowire bean in Condition? There is an next example. We have 2 implementation of FileManager. One of implementation should be initialize in depends on property 'platform'. Properties handles via Archaius. @Component public class AwsPlatformCondition implements Condition { @Autowired private ArchaiusProperties archaiusProperties; @Override public boolean matches(ConditionContext...

Using R, return column numbers where a condition is met

r,numbers,condition
I have the following matrix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 [1,] 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0...

How to swap the lines in a file that match a condition using Shell script

unix,match,condition,swap,lines
I have a file in which 28th character of every line is either "A" or "D". I want to swap the lines in such a way that the first line of the file should have the 28th character as "D" and the second line of the file should have 28...

Change condition in LINQ by another condition

c#,linq,condition
I have these two LINQ lines which are only different in one condition. node.Image.Tag == null and node.Image.Tag != null if (treeSelectedNode.Image.Tag == null) { radNode = tree.Find(node => node.Level == 0 && node.Image.Tag == null && node.Text.Equals(treeSelectedNode.Text)); } else { radNode = tree.Find(node => node.Level == 0 && node.Image.Tag...

Java: if, switch or question mark double point

java,if-statement,switch-statement,condition
Which of the following methods is the fastest? int i; String s; 1. If Else if(i == 0) s = "Case A" else if(i == 1) s = "Case B" else s = "Case C" 2. Switch switch(i) { case 0: s = "Case A"; break; case 1: s =...

python 2.7 chained conditions If Else not working. What's wrong?

python,python-2.7,if-statement,condition
I can't figure out why the following doesn't work. # Example print "So, yes or no?" answer = raw_input() print answer if answer == "Yes": print "Yes indeed!" elif answer == "yes" or "y": print "Oh yeah!" elif answer == "No": print "No it isn't!" elif answer == "no" or...

Copy subdirectories if they contain a specific file in Ant

xml,recursion,ant,condition
Really new to Ant and I have been trying to figure that out but could not... Let say I have a structure like that : Root |-data |-dir1 |-include.xml |-subdir1 |-file1 |-file2 |-include.xml |-subdir2 |--dir2 |-file1 |-include.xml |--dir3 |--dir4 |-file1 |-include.xml |--dir5 |-build.xml |-other files I'd like to copy the...

WiX: Install component based on ComboBox selection

combobox,wix,condition
I'm trying to create an installer which installs some components based on the selection of a Combobox but it seems like the condition isn't working. I declared the Combobox as the following: ... <UI> <ComboBox Property="Option"> <ListItem Text="Red" Value="red" /> <ListItem Text="Blue" Value="blue" /> <ListItem Text="Green" Value="green" /> </ComboBox> ......

MySQL SUM of field with conditon, IF(SUM(bill_1) IS NULL, '99', SUM(bill_1)) AS tot_bill_1

mysql,if-statement,join,sum,condition
I want SUM(tot_bill_1+tot_bill_2) AS total, but it's not work SELECT *, IF(SUM(bill_1) IS NULL, '99', SUM(bill_1)) AS tot_bill_1, IF(SUM(bill_2) IS NULL, '10', SUM(bill_2)) AS tot_bill_2, SUM(tot_bill_1+tot_bill_2) AS total FROM billing Any ideas?...

What _L1 : _L2: mean? [closed]

java,android,logic,condition
hi i have decompiled an android project but i dont know what this part mean please help with example code. what does _L1 _L2 do ? tanks i = 0; _L5: if (i < AnswerTexts.size()) goto _L2; else goto _L1 _L1: j = 0; _L6: if (j < AnswerTexts.size()) goto...

What condition do I have to specify to run installation sequence during install and uninstall too?

installation,windows-installer,condition,installshield,uninstall
I'd like to use ScheduleReboot Install sequence to run on install and uninstall too. (In Installshield) What condition do I have to specify for that?...

Dynamical SUMIF command

excel,sum,condition
If it is possible, I'd like to create a formula that will allow me the following: Formula must be in the entire column or in this example, in the range B1:B5. The formula is based on a condition, that when the total sum of cells from column A is lower...

mod_rewrite RewriteCond falsly doesn't match pattern

regex,mod-rewrite,condition
This is driving me insane. I have a very simple pattern I wish to match: RewriteEngine On RewriteRule .? - [E=tpl:%{REQUEST_URI}] RewriteCond ${REQUEST_URI} a RewriteRule .? - [E=tpl:presentation] RewriteRule .? index.php?tpl=%{ENV:tpl} [QSA,L] Within index.php I currently simply var_dump($_REQUEST); to check the value of tpl. Whenever I access the URI /aaa_foo/bar...

SQL Repeated Condition in Two Tables

sql,variables,coding-style,condition
I am a beginner to SQL, and I am having trouble getting rid of repeated code. I have a condition "AccountId=20" that I use twice in a SQL query. The SQL looks something like: DELETE FROM Table_A WHERE FunctionId IN (Select FunctionId FROM Table_B WHERE AccountId=20); DELETE FROM Table_B WHERE...

Objective C: -1 < 0 return false

objective-c,condition
Is there any difference between this 2? int count = 0; for (UIView *view in scrollView.subviews) { NSLog(@"%d < %d", [json[@"images"] count] - 1, count); // Output: -1 < 0 if ([json[@"images"] count] - 1 < count) break; } and int count = 0, maxIndex = [json[@"images"] count] - 1;...

SQL query with condition

sql,sql-server,condition
So I have a table for every item in my sales order, which contains the item ID or just a description if it's not a real item, the table looks like this: SalesOrderLine: |ID | SOI_IMA_RecordID | SOI_LineNbrTypeCode | SOI_MiscLineDescription | |1 | 2 | Item | XYZ | |2...

for each loop: how to step out of conditions

loops,vbscript,condition
I am stuck at creating a loop for testing filenames with VBScript. To be precise, I am trying to perform something like a jump in a For Each loop. The loop should test all files in a folder and in some cases it should delete some files. But while running,...

Excel adding data based on current data

excel,excel-vba,data,add,condition
I'm trying to write a macro that i can run which will allow me to simply sort a range of orders into what i like to call categories. The basic idea is that we get orders through, and we generally have to print a different type of shipping label for...

Grails hibernate create criteria multiple AND OR Conditions

hibernate,gorm,condition,createcriteria
I was able to do 3 conditions query using grails/Hibernate create Criteria as follows def c = Domain.createCriteria() c.list(max: map.max ?: 10, offset: map.offset ?: 0) { and { "colStatus" in status "code" in codes } and { or { ilike("pCode", pCode) ilike("pDesc", pCode) } } order("DateCol3", "desc") } Now...

R Date not in character list

r,date,condition
I have a data frame with several variables, among those, a date (df$date) in Date format. I also have list with dates, in character format (e.g. "2013-07-14"). I need to remove the list dates from the data frame. I have tried the following but none of them is working. datestoremove...

How to create nested list using special condition in python

python,list,nested,condition
I really appreciate an answer for my problem. So problem: I have a list Plist=[[x1,y2,str_1],[x2,y2,str_1],[x3,y3,str_1],[x4,y4,str_2],[x5,y5,str_2]] and would like to convert it into a nested list (would avoid dict now): newPlist=[[[x1,y2,str_1],[x2,y2,str_1],[x3,y3,str_1]],[[x4,y4,str_2],[x5,y5,str_2]]] I know how to sort it out based on length, yet cannot figure it out if I have a special...

How do I create a loop which checks these values? [closed]

java,loops,substring,condition
If I had a numberical idno value, how would I find the ones >=5000 and < 5000? Would i use idno.substring(7,11) and then check the conditions if >=5000 print Male if <5000 print Female How would I perform this?...

Excel: conditional formatting, check if column contains text from other sheet

excel,condition,conditional-formatting
First sheet: First name Last name Role Valeria Bianchi Admin Evelise Verdi Teacher Daniele Rossi Teacher Annamaria Neri Admim Anna Gialli Manager Anna Bella Proietti Teacher Simona Ciaociao Manager Elisabetta Lilla Admin Second sheet: Email Name [email protected] Valeria Bianchi [email protected] Daniele Rossi [email protected] Annamaria Neri [email protected] Anna Gialli [email protected] Simona...

Using counter in condition in python

python,if-statement,condition
Imagine I have the following code: i=0 while True: if flag==True and i=i+5: func() . . . i+=1 break shouldn't be i==i+5? I want to run func() each 5 times....

How to apply If Then to a range of cells using VBA

vba,condition
I'm new to VBA and one of the examples I'm working through (below), is using an If function; in this case, depending on what the 'score' is in A1, some text will be displayed in B1. I understand that alright, but I was wondering how you would apply that to...

What does this if assignment/statement mean in C++

c++,if-statement,condition,variable-assignment,conditional-statements
Our professor gave us this code. It assigns a value to a char[] depending on the value of the first index in the array. He said it was an if statement but I've never seen one like this. I'm new to c++ temp.byte[0] = byte[0] == '0' ? '1' :...

PHP - How can regex replace a string by condition

php,regex,replace,condition
I have a string: {include "abc"} {literal} function xyz() { "ok"; } {/literal} {abc} {123 } I just want to replace all { to {{ and } to }} not in {literal} tag. The result will be: {{include "abc"}} {{literal}} function xyz() { "ok"; } //... something contain { and...

Replace the characters in every line of a file, if it match a condition - Unix

unix,replace,sed,match,condition
I have a file "dummy" in which: If 15 character of the file matches with "R" and 28 character of the file matches with "D" then 53-56 characters should be replaced with 0. I have tried using the below script, but it's not working. for i in `cat dummy` do...

need help on condition in android

android,if-statement,condition
this is my code, If add the if statement in line No 105 then program crashes, if i removed this then my code is working. But without this i can't solve my code. Please can anyone tell me what could be the problem or what am i doing wrong? public...

How do I query a table with conditions from related table with Laravel 5

laravel,eloquent,condition,relationship
I have two tables, table users: id, name, etc table videos: id, user_id, etc Model: Video public function user() { return $this->belongsTo('App\Models\User'); } I want to select all videos where it is owned by the user "Max". I have tried thing like the following: $Videos = \App\Models\Video::with('user')->where('user.name','=','Max')->get(); Unknown column 'user.name'...

Sum of one column in special condition [closed]

c#,sql,sum,condition
I have two table, table1 and table2. table2 foreign key (fk column) is table1 primary key (id column). table2.column3 is bit(True/False). I want to calculate sum of table2.column2 if table2.column3 True, and save result of sum in table1's row which that id equals table2 foreign key. Is this possible? Can...

Retrieve a value from an array and make a condition

php,arrays,condition
I have the following code that I am using on WordPress: if($terms && !is_wp_error($terms) ) { $colors = array(); foreach ($terms as $term) { $colors[] = '\'' . $term->slug . '\''; } } print_r(array_values($thePack)); The variable $color now is a basic Array, which print_r displays like this: Array ( [0]...

2 join conditions codeigniter giving error

codeigniter,join,condition
I have 2 tables - for orders and for documents for these orders. I want to show all orders from first table and if there are documents for these orders, to show date of documents(I take date from table documents). I'm trying to make 2 join conditions because in table...

is it possible to write regular expression in $cond in MongoDB

regex,mongodb,condition
I need to use $cond to combine differenet column, and one $cond I need to write is as following: create_widget: { $sum:{ $cond:[{$and: [ {$eq: ['$Method', 'POST']}, {Url:{$regex: /.*\/widgets$/}} ]}, 1, 0] } } and this code is not right, it seems, regular expression can not be put here.Is there...

If : (Why is there no value assigned?)

python,variables,if-statement,branch,condition
Can anybody tell why is there no value assigned to begin after the condition at if begin: and just end with a colon instead? May I know what does it mean? if begin: begin = int(begin) end = int(raw_input("End:")) print "word[", begin,":",end,"] ", print word[begin:end] raw_input("\n\nPress the Enter Key to...