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 8921601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:35:11+00:00 2026-06-15T06:35:11+00:00

I have a table below with various column. I want to update the values

  • 0

I have a table below with various column.
I want to update the values in certain feilds based on a value on other fields.

My Table is here

DROP TABLE IF EXISTS my_table; 
CREATE TABLE my_table
(id INT NOT NULL AUTO_INCREMENT UNIQUE,
Shot VARCHAR(4),
lay VARCHAR(15) NOT NULL,
lay_avaibility VARCHAR(15) NOT NULL,
blk VARCHAR(10) NOT NULL,
blk_avaibility VARCHAR(15) NOT NULL,
pri VARCHAR(10) NOT NULL,
pri_avaibility VARCHAR(15) NOT NULL,
ani VARCHAR(10) NOT NULL,
ani_avaibility VARCHAR(15) NOT NULL,
status VARCHAR(5)
);

INSERT INTO my_table VALUES
(1,'SH01','1863','Offline','1863','Offline','P4645','Offline','P4557','Offline','Over'),
(2,'SH02','1863','Offline','P4645','Offline','P4557','Offline','1863','Offline','Over')
(3,'SH03','P4645','Offline','P4557','Offline','1863','Offline','1863','Offline','WIP'),
(4,'SH04','1863','Offline','P4645','Offline','P4557','Offline','1863','Offline','RTK'),
(5,'SH05','1863','Offline','1863','Offline','P4645','Offline','P4557','Offline','WIP'),
(6,'SH06','P4557','Offline','P4645','Offline','P4645','Offline','P4557','Offline','WIP');

SELECT * FROM my_table;

+----+------+-------+----------------+-------+----------------+-------+----------------+-------+----------------+--------+
| id | Shot | lay   | lay_avaibility | blk   | blk_avaibility | pri   | pri_avaibility | ani   | ani_avaibility | status |
+----+------+-------+----------------+-------+----------------+-------+----------------+-------+----------------+--------+
|  1 | SH01 | 1863  | Offline        | 1863  | Offline        | P4645 | Offline        | P4557 | Offline        | Over   |
|  2 | SH02 | 1863  | Offline        | P4645 | Offline        | P4557 | Offline        | 1863  | Offline        | Over   |
|  3 | SH03 | P4645 | Offline        | P4557 | Offline        | 1863  | Offline        | 1863  | Offline        | WIP    |
|  4 | SH04 | 1863  | Offline        | P4645 | Offline        | P4557 | Offline        | 1863  | Offline        | RTK    |
|  5 | SH05 | 1863  | Offline        | 1863  | Offline        | P4645 | Offline        | P4557 | Offline        | WIP    |
|  6 | SH06 | P4557 | Offline        | P4645 | Offline        | P4645 | Offline        | P4557 | Offline        | WIP    |
+----+------+-------+----------------+-------+----------------+-------+----------------+-------+----------------+--------+
6 rows in set (0.00 sec)

SELECT VERSION();

+-----------+
| VERSION() |
+-----------+
| 5.5.23    |
+-----------+
1 row in set (0.02 sec)

i want to update all lay_avaibility,blk_avaibility,pri_avaibility,ani_avaibility columns to ‘Online’ where lay,pri,blk,ani columns have ‘1863’ ie., the final table should look like below

+----+------+-------+----------------+-------+----------------+-------+----------------+-------+----------------+--------+
| id | Shot | lay   | lay_avaibility | blk   | blk_avaibility | pri   | pri_avaibility | ani   | ani_avaibility | status |
+----+------+-------+----------------+-------+----------------+-------+----------------+-------+----------------+--------+
|  1 | SH01 | 1863  | Online         | 1863  | Online         | P4645 | Offline        | P4557 | Offline        | Over   |
|  2 | SH02 | 1863  | Online         | P4645 | Offline        | P4557 | Offline        | 1863  | Online         | Over   |
|  3 | SH03 | P4645 | Offline        | P4557 | Offline        | 1863  | Online         | 1863  | Online         | WIP    |
|  4 | SH04 | 1863  | Online         | P4645 | Offline        | P4557 | Offline        | 1863  | Online         | RTK    |
|  5 | SH05 | 1863  | Online         | 1863  | Online         | P4645 | Offline        | P4557 | Offline        | WIP    |
|  6 | SH06 | P4557 | Offline        | P4645 | Offline        | P4645 | Offline        | P4557 | Offline        | WIP    |
+----+------+-------+----------------+-------+----------------+-------+----------------+-------+----------------+--------+
  • 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-06-15T06:35:13+00:00Added an answer on June 15, 2026 at 6:35 am

    You should be able to use a CASE statement like this with an Update command:

    UPDATE my_table 
        SET lay_availability = CASE WHEN lay = '1863' THEN 'Online' ELSE lay_availability END,
        blk_availability = CASE WHEN blk = '1863' THEN 'Online' ELSE blk_availability END,
        pri_availability = CASE WHEN pri = '1863' THEN 'Online' ELSE pri_availability END,
        ani_avaibility   = CASE WHEN ani = '1863' THEN 'Online' ELSE ani_avaibility END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table as below: id value ------------------------- 1 1 5 1 7
I want to do a ranking grid. I have a table with different values
I have CSS definitions for various elements around Table as shown below (Details omitted,
i have the table below <tr id=group_1>...</tr> <tr id=el>...</tr> <tr id=el>...<tr> <tr id=group_2></tr> <tr
I have a table like below: Table A ---------- ID Field1 Field2 Field3 1
I have a table as below ID Date 1 Null 1 Null 1 Null
I have a table as below Name Priority Date ------------------------- A 2 d1 B
I have a table like below: EmployeeId EmployeeName RequestId RequestName EmployeeId RequestId I need
I have a table as below dbo.UserLogs ------------------------------------- Id | UserId |Date | Name|
I have a table with below structure. I am not having control over changing

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.