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

  • Home
  • SEARCH
  • 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 970737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:51:06+00:00 2026-05-16T02:51:06+00:00

I have written the following SQL statement in MySQL : USE my_database; SELECT *

  • 0

I have written the following SQL statement in MySQL :

USE my_database;
SELECT * FROM some_table WHERE some_column IN (1, 2, 3);

This returns a set of rows that have a column value which is a key into a row of another table (call it some_other_table).

a b c d <--this is the column with the key
      1
      2
      3

I want to say, look up all of the rows in another table with value 1, and do something (null out some column)

Any help is appreciated.

  • 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-16T02:51:06+00:00Added an answer on May 16, 2026 at 2:51 am

    Yes, you can use the multiple-table UPDATE syntax:

    UPDATE some_other_table
    JOIN   some_table ON (some_table.some_key = some_other_table.id)
    SET    some_other_table.some_field = NULL
    WHERE  some_table.some_column IN (1, 2, 3);
    

    Example:

    CREATE TABLE some_table (id int, some_column int, some_key int);
    CREATE TABLE some_other_table (id int, some_field int);
    
    INSERT INTO some_table VALUES (1, 1, 1);
    INSERT INTO some_table VALUES (2, 2, 2);
    INSERT INTO some_table VALUES (3, 3, 3);
    INSERT INTO some_table VALUES (4, 4, 4);
    INSERT INTO some_table VALUES (5, 5, 5);
    
    INSERT INTO some_other_table VALUES (1, 10);
    INSERT INTO some_other_table VALUES (2, 20);
    INSERT INTO some_other_table VALUES (3, 30);
    INSERT INTO some_other_table VALUES (4, 40);
    

    Before:

    SELECT * FROM some_table;
    +------+-------------+----------+
    | id   | some_column | some_key |
    +------+-------------+----------+
    |    1 |           1 |        1 |
    |    2 |           2 |        2 |
    |    3 |           3 |        3 |
    |    4 |           4 |        4 |
    |    5 |           5 |        5 |
    +------+-------------+----------+
    5 rows in set (0.00 sec)
    
    SELECT * FROM some_other_table;
    +------+------------+
    | id   | some_field |
    +------+------------+
    |    1 |         10 |
    |    2 |         20 |
    |    3 |         30 |
    |    4 |         40 |
    +------+------------+
    4 rows in set (0.00 sec)
    

    After:

    SELECT * FROM some_table;
    +------+-------------+----------+
    | id   | some_column | some_key |
    +------+-------------+----------+
    |    1 |           1 |        1 |
    |    2 |           2 |        2 |
    |    3 |           3 |        3 |
    |    4 |           4 |        4 |
    |    5 |           5 |        5 |
    +------+-------------+----------+
    5 rows in set (0.00 sec)
    
    SELECT * FROM some_other_table;
    +------+------------+
    | id   | some_field |
    +------+------------+
    |    1 |       NULL |
    |    2 |       NULL |
    |    3 |       NULL |
    |    4 |         40 |
    +------+------------+
    4 rows in set (0.00 sec)
    

    UPDATE: Further to comments below.

    Another example:

    CREATE TABLE amir_effective_reference (class int, inst int, rln int, rclass int, rinst int, chg int, typ int);
    CREATE TABLE amir_effective_change (chg int, txn int, rltn int, entry int, effective int);
    
    INSERT INTO amir_effective_reference VALUES (1, 100, 1, 50, 20, 10, 5000);
    INSERT INTO amir_effective_change VALUES (10, 100, 100, 500, 200);
    

    Result:

    UPDATE amir_effective_change 
    JOIN   amir_effective_reference ON (amir_effective_reference.chg = amir_effective_change.chg) 
    SET    amir_effective_change.effective = NULL 
    WHERE  amir_effective_change.rltn IN (100);
    
    SELECT * FROM amir_effective_change;
    +------+------+------+-------+-----------+
    | chg  | txn  | rltn | entry | effective |
    +------+------+------+-------+-----------+
    |   10 |  100 |  100 |   500 |      NULL |
    +------+------+------+-------+-----------+
    1 row in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 516k
  • Answers 516k
  • 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 To ignore facebook subdomains you can ensure that $parse_author_url['host'] is… May 16, 2026 at 6:54 pm
  • Editorial Team
    Editorial Team added an answer This blog post should get you going. Quoted from post:… May 16, 2026 at 6:54 pm
  • Editorial Team
    Editorial Team added an answer Even though your phone is rooted applications will still run… May 16, 2026 at 6:54 pm

Trending Tags

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

Top Members

Related Questions

I want to create the following T-SQL statement: SELECT SUM (sa.Amount) as 'SumAmount', SUM(sa.Cost)
I have written the following piece of code ( sql clr stored procedure )
I have written this T-SQL script to roll up duplicate rows in a database
I have written the following function: -- Gets stats for all markets CREATE OR
I have written a SQL query that works just fine, but am having a
Can anyone please help me on the following: I have created a SQL Server
I have C# .net project with SQL Server 2008 written in Visual Studio 2008.
I have created a MySQL function to determine if a set of latitude and
Alright here's the situation, I have an application written in the Zend_Framework, that is
I have written an integrationtest that fails: [Test] public void Find_WorkItemWithMatchingDescriptionExistsInRepository_ReturnsWorkItem() { // arrange

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.