Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 15 wrz 2008 · From this link, we can understand IF THEN ELSE in T-SQL: IF EXISTS(SELECT * FROM Northwind.dbo.Customers WHERE CustomerId = 'ALFKI') PRINT 'Need to update Customer Record ALFKI' ELSE PRINT 'Need to add Customer Record ALFKI' IF EXISTS(SELECT * FROM Northwind.dbo.Customers WHERE CustomerId = 'LARSE') PRINT 'Need to update Customer Record LARSE ...

  2. 28 maj 2024 · In this article, we explored different options for executing IF-THEN logic in a SQL SELECT statement. These options include using CASE , IIF() , and CHOOSE() . Furthermore, if we want a query that’s used in almost every dialect, we must choose the CASE statement.

  3. 8 Answers. Sorted by: 1134. SELECT id, IF (type = 'P', amount, amount * -1) as amount FROM report. See https://dev.mysql.com/doc/refman/8.0/en/flow-control-functions.html. Additionally, you could handle when the condition is null. In the case of a null amount: SELECT id, IF (type = 'P', IFNULL (amount,0), IFNULL (amount,0) * -1) as amount FROM ...

  4. 7 gru 2023 · If you want to do if-else-then logic in select, where or anywhere else in a statement, you need a case expression. This is a series of when clauses that the database runs in order: For example, if you want to map exam correct percentages to grade letters according to these rules:

  5. 3 wrz 2024 · Imposes conditions on the execution of a Transact-SQL statement. The Transact-SQL statement that follows an IF keyword and its condition is executed if the condition is satisfied: the Boolean expression returns TRUE.

  6. 26 wrz 2023 · Step 1: Basic Syntax. The IF...THEN statement in SQL is often used in conjunction with the CASE expression. The basic syntax goes like this: SELECT . column1, column2, ... CASE WHEN condition1 THEN result1. WHEN condition2 THEN result2. ... ELSE else_result. END AS alias_name. FROM . your_table; column1, column2, etc.:

  7. 26 sty 2024 · The IFTHEN statement in MySQL allows you to execute a block of SQL code if a condition is true. The basic syntax for the IF…THEN construct is as follows: BEGIN . IF condition THEN. -- Statements to execute if the condition is true END IF; END;

  1. Ludzie szukają również