SQL select and update on one sql statement

Posted on 2007-07-30
Last Modified: 2010-03-20
Can you have a select and update statemnt execute in one sql statement. I have a asp script and instead of creating a recordset to get the value then add 1 to it I'd like to get the value of a field(int) and update it in one sql statement if a flag = true.

if flag = true
e.g sql= select myvalue from tbl_main. add 1 to myvalue.
end if

Question by:cseink
    LVL 142

    Accepted Solution

    if flag = true
      sql = " update tbl_main set myvalue = myvalue + 1 "
    end if

    Author Comment

    Perfect. Thanks

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Parameterised queries 4 54
    Excel to create SQL insert 7 28
    Php Sql Query 7 19
    Pl/SQL Query 31 38
    As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
    'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now