GithubHelp home page GithubHelp logo

Comments (4)

dcherednik avatar dcherednik commented on May 15, 2024

Hello.
Probably UPSERT can help with your task. https://ydb.tech/en/docs/yql/reference/syntax/upsert_into

from ydb.

vladd11 avatar vladd11 commented on May 15, 2024

Hello. Probably UPSERT can help with your task. https://ydb.tech/en/docs/yql/reference/syntax/upsert_into

No, it can't.

UPSERT INTO users(id, phone, sms_code, sms_code_expiration)
VALUES (?id, ?phone, ?sms_code, ?sms_code_expiration);

will update id column of row, but I need to do this only if row doesn't exist.

from ydb.

fomichev3000 avatar fomichev3000 commented on May 15, 2024
UPSERT INTO users(id, phone, sms_code, sms_code_expiration)
VALUES (?id, ?phone, ?sms_code, ?sms_code_expiration);

will update id column of row, but I need to do this only if row doesn't exist.
Technically, updating id with the same value leads to just updating values. To my mind result would be the same, either you call INSERT INTO ... ON DUPLICATE KEY <update all fields> or UPSERT ... <specify all fields>. Do you see any controversial example?

from ydb.

uh-zuh avatar uh-zuh commented on May 15, 2024
INSERT INTO table1 (id, value, create_time)
VALUES ($id, $value, $create_time)
ON DUPLICATE KEY
UPDATE value = $value;

but UPSERT will modify create_time too.

from ydb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.