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 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

Related Questions

I have written the following simple test in trying to learn Castle Windsor's Fluent
I have written something that uses the following includes: #include <math.h> #include <time.h> #include
I have written a KornShell (ksh) script that sets an array the following way:
I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class
(All of the following is to be written in Java) I have to build
I have written an AIR Application that downloads videos and documents from a server.
I have written some code in my VB.NET application to send an HTML e-mail
I have written a site in Prototype but want to switch to jQuery. Any
I have written a ruby script which opens up dlink admin page in firefox
I have written an AppleScript which when supplied with a Windows network link, will

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.