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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:29:52+00:00 2026-06-01T04:29:52+00:00

I’ve been muddling through using MySQL for some time, but it’s still not really

  • 0

I’ve been muddling through using MySQL for some time, but it’s still not really ‘in’ my brain yet, so I’m hoping I can make myself understood here, and that someone else can help me clear this particular cerebral mire of mine. 🙂

I have two MySQL tables, writers and abstracts, and an intersection table writer_abstract that joins them in a many-to-many relationship.

In the abstracts table, there’s a field accepted (a boolean) to indicate whether or not a certain abstract has been accepted for publication. Similarly, in the writers table, there is a field published (also a boolean) that indicates whether or not an author has had anything published (or accepted for publication).

The intersection table is very simple: it has an auto-incrementing id field, a writer_id field, and an abstract_id field. I can select back and forth between writers and abstracts using the intersection table without problems.

When an abstract is accepted or rejected, abstracts.accepted is set to either TRUE or FALSE.

What I would like to do is, in a single MySQL statement, update writers.published in all rows and set it to TRUE if there are any abstracts by that author whose accepted field is TRUE. But I can’t figure out how to phrase the UPDATE statement to get it to work.

My best efforts are something like this:

UPDATE writers LEFT JOIN
    ( SELECT abstracts.id AS aid, abstracts.accepted AS aacc FROM writer_abstract
      LEFT JOIN abstracts ON writer_abstract.abstract_id = writers.id
      WHERE aacc = TRUE AND writers.id = writer_abstract.author )
AS res
SET published = TRUE

Obviously, this doesn’t work (I have an error in my syntax near SET published = TRUE). But this can’t be something that isn’t fairly easily done, surely?!

Any help much appreciated! 🙂

Update

Based on KingFisher’s reply, here is the version that actually did what I wanted (note the RIGHT JOIN instead of the LEFT JOIN—the former naturally affected all rows in writers, which wasn’t what I wanted):

UPDATE writers RIGHT JOIN
    ( SELECT author, accepted FROM writer_abstract
      LEFT JOIN abstracts ON writer_abstract.abstract_id = writers.id
      WHERE accepted = TRUE )
AS res ON res.author = writers.id
SET published = TRUE
  • 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-01T04:29:54+00:00Added an answer on June 1, 2026 at 4:29 am

    You should have on clause with join of writers table and your subquery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Been going through some framework classes using reflector and noticed a number of the
Been looking around the web, but not found anything so far... can anyone help?
Been using PHP/MySQL for a little while now, and I'm wondering if there are
been looking but not much luck, i want to create a function that only
Been developing an application using PHP's PEAR framework, but ran into an issue where
been recoding my site using code igniter. I am having some quirks with my
Been searching all around but still cannot find a solution for this problem. My
Been a while since I've dealt with ASP.NET and this is the first time
Been trying to upgrade my subversion installation, but due to (what I believe) are
been searching for a quick example of sorting a IQueryable (Using Linq To SQL)

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.