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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:51:00+00:00 2026-05-14T00:51:00+00:00

This is what i am doing update t1 set x=a,y=b where a and b

  • 0

This is what i am doing

update t1 set x=a,y=b where a and b are obtained from (select query here)
  1. I know the select query
  2. The select query returns multiple results which are the same
  3. When I use group by or distinct query execution slows down considerably
  4. a and b are forward references so mysql reports an error
  5. I want to set a equal to the value obtained in the first row and b equal to the value obtained in the first row for the respective columns, to avoid group by. I don’t know how to refer to the first result from the select query.

How can i achieve all this?

  • 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-14T00:51:01+00:00Added an answer on May 14, 2026 at 12:51 am

    LIMIT specifies the number of rows to return from the beginning of the result set:

    SELECT * FROM t2 LIMIT 1; # Retrieve 1st row

    LIMIT in your case is applied in the subquery in your from clause.

    These linsk can help you out with update that uses a subquery:

    Update with Subquery

    Subqueries in MySQL, Part 1

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

Sidebar

Related Questions

I'm doing it this way: UPDATE products SET products_image = (SELECT products_image FROM products
Imagine the following sql query: UPDATE MYTABLE SET COL2 = (SELECT COL2 + 1
I'm doing this query: SomeObject.objects.annotate(something=Avg('something')).order_by(something).all() I normally have an aggregate field in my model
I'm trying to update multiple rows in one table in MySQL database by doing
I have to code this logic: UPDATE imported SET col1 = 'first' WHERE col2
I'm getting and error using this syntax: update table set field1 = (field1+' -
I currently have something like this: UPDATE table1 SET column1 = REPLACE(column1, 'abc', 'abc1')
I wrote the following query: UPDATE king_in SET IN_PNSN_ALL_TP_CNTRCT_CD = IN_PNSN_ALL_TP_CNTRCT_CD + '3' WHERE
How can I set a variable while doing an Update statement? I can't seem
I need to know the proper way of doing this. I have a form

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.