Search results
1 cze 2015 · If you specify ON DUPLICATE KEY UPDATE, and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, an UPDATE of the old row is performed. Please read URL for more details.
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();
19 lip 2022 · update customers_dim cd set ( full_name, update_datetime ) = ( select cs.full_name, systimestamp from customers_stage cs where cs.customer_id = cd.customer_id ) where exists ( select null from customers_stage ce where ce.customer_id = cd.customer_id )
5 gru 2019 · I come from using mostly ms sql, but also sybase and mysql. Now I am working in a company where they use oracle, so I am learning a new dialect. I use exists to determine if I need to do an update or insert in ms sql. IF EXISTS(SELECT 'True' FROM TABLE WHERE COLUMN = @ID) BEGIN UPDATE TABLE; END ESLE BEGIN INSERT INTO TABLE; END
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 ...
9 cze 2023 · Have you ever needed to update data that was already in a table? Learn how to do this with the SQL UPDATE Statement. This post applies to Oracle, SQL Server, MySQL, and PostgreSQL.
26 sty 2012 · UPDATE ea SET GTL_UW_APPRV_DT = DNTL_UW_APPRV_DT FROM EMPLOYER_ADDL AS ea WHERE EXISTS ( SELECT 1 FROM EMP_PLAN_LINE_INFO AS ep WHERE ep.GR_NBR = ea.GR_NBR AND ep.LINE_CD = 50 ); However, if you can derive this information from a query, why update the table?