Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 400793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:58:26+00:00 2026-05-12T16:58:26+00:00

Say I have this two-column table id | column_test 1 | NULL 2 |

  • 0

Say I have this two-column table

 id  | column_test

 1   | NULL

 2   | NULL

 3   | NULL 

…

as you see, the column_test column now all have value ‘NULL’. Now I want to do an update to this table and the final status should look like :

 id  | column_test

 1   | a

 2   | b

 3   | c

…

I know little about compound SQL statements, it looks the query to be used is a small SQL program which is probably going to have local variables involved. Unfortunately I don’t know the exact syntax yet(I’ve tried to build the query myself in the last 20-30 minutes), maybe I can find some SQL gurus here to help me out.-)

[edit:let’s stick to mysql.]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:58:26+00:00Added an answer on May 12, 2026 at 4:58 pm

    In MySQL:

    CREATE TABLE mytable (id INT NOT NULL, column_test CHAR(1));
    
    INSERT
    INTO    mytable (id)
    VALUES
    (1),
    (2),
    (3),
    (4);
    
    SET @r := 0;
    UPDATE  mytable
    SET     column_test = CHAR(96 + (@r := @r + 1))
    WHERE   column_test IS NULL
    ORDER BY
            id;
    
    SELECT  *
    FROM    mytable;
    

    In SQL Server:

    WITH    q AS
            (
            SELECT  *, ROW_NUMBER() OVER (ORDER BY id) AS rn
            FROM    mytable
            WHERE   column_test IS NULL
            )
    UPDATE  q
    SET     column_test = CHAR(96 + rn)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 220k
  • Answers 220k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Short answer: no. Long answer: there are ways to achieve… May 12, 2026 at 11:54 pm
  • Editorial Team
    Editorial Team added an answer You perform step 6, the Forms Library module performs step… May 12, 2026 at 11:54 pm
  • Editorial Team
    Editorial Team added an answer Yes, it's possible to create a class at runtime from… May 12, 2026 at 11:54 pm

Related Questions

I have a system which defines repeating patterns of days. Each pattern has a
Say we have two tables in an MS Access db: Service Users: | ID
im in the beginning of the complete restyle of an my web application, and
The problem itself is simple, but I can't figure out a solution that does

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.