Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 1 lut 2010 · Here's a query to update a table based on a comparison of another table. If record is not found in tableB, it will update the "active" value to "n". If it's found, will set the value to NULL. UPDATE tableA LEFT JOIN tableB ON tableA.id = tableB.id SET active = IF(tableB.id IS NULL, 'n', NULL)"; Hope this helps someone else.

  2. Use the GREATEST() function (this needs a CAST() as well): UPDATE my_table SET comments = GREATEST(CAST(comments AS signed)-3, 0) WHERE something = 123; or the IF() function: UPDATE my_table SET comments = IF(comments>3, comments-3, 0) WHERE something = 123; or a CASE expression:

  3. In this article, we would like to show you UPDATE query with IF condition in MySQL. Quick solution: UPDATE `table_name` SET `column_name` = IF(condition , if_true, if_false); Practical example. To show UPDATE query with IF condition, we will use the following users table:

  4. 11 lip 2024 · The IF () function in MySQL is a powerful tool that allows you to implement conditional logic directly within your SQL queries. It takes three parameters: a condition to evaluate, a value to return if the condition is true, and a value to return if the condition is false.

  5. DELIMITER // CREATE FUNCTION VerboseCompare (n INT, m INT) RETURNS VARCHAR(50) BEGIN DECLARE s VARCHAR(50); IF n = m THEN SET s = 'equals'; ELSE IF n > m THEN SET s = 'greater'; ELSE SET s = 'less'; END IF; SET s = CONCAT('is ', s, ' than'); END IF; SET s = CONCAT(n, ' ', s, ' ', m, '.');

  6. www.mysqltutorial.org › mysql-stored-procedure › mysql-if-statementMySQL IF Statement - MySQL Tutorial

    Use IF...THEN...ELSE statement to execute a block of statements if a specified condition is true and an alternative block of statements if the condition is false. Use IF...THEN...ELSEIF...ELSE statement to evaluate multiple conditions sequentially and execute corresponding blocks of statements based on the first true condition, with an optional ...

  7. 24 lis 2015 · I want to take the below SQL and if there is no update found, I want to add a 0 in that record. Is this possible from a single query? Currently I utilize this query to update records and then go back and run a query to add 0 in null fields.

  1. Ludzie szukają również