Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 17 lis 2010 · I want to add a row to a database table, but if a row exists with the same unique key I want to update the row. For example: INSERT INTO table_name (ID, NAME, AGE) VALUES(1, "A", 19); Le...

  2. 17 paź 2024 · MySQL provides two ways to insert a row into a table or update the row if it already exists. We can use the INSERT INTO … ON DUPLICATE KEY UPDATE syntax or the REPLACE statement.

  3. If a subquery returns any rows at all, EXISTS. subquery is TRUE, and NOT EXISTS. subquery is FALSE. For example: SELECT column1 FROM t1 WHERE EXISTS (SELECT * FROM t2); Traditionally, an EXISTS subquery starts with SELECT *, but it could begin with SELECT 5 or SELECT column1 or anything at all.

  4. 29 kwi 2015 · IF EXISTS (select * from users where username = 'something') THEN. update users set id= 'some' where username = 'something'; ELSE. insert into users (username) values ('something'); END IF; end $$. delimiter ; and call it like this: call select_or_insert();

  5. You can use the INSERT INTO …. ON DUPLICATE KEY UPDATE statement in MySQL to achieve this. This statement will insert a new row into the table, or if a duplicate key violation occurs (i.e., a row with the same primary or unique key exists), it will update the existing row with the new values. Here’s the SQL query:

  6. 27 sty 2024 · Here’s how you would insert a new product or update the quantity if it already exists. INSERT INTO products (id, name, quantity) VALUES (1, 'Widget', 10) ON DUPLICATE KEY UPDATE quantity = VALUES(quantity) + 10; Here if a product with id=1 already exists, its quantity will be updated by adding 10 more to it. Otherwise, a new product will be ...

  7. 23 cze 2013 · I am trying to UPDATE values from a table, but I need to add some conditions. I found the function CASE, but I am not if it is the best method. Here is an example.

  1. Ludzie szukają również