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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:17:02+00:00 2026-05-28T08:17:02+00:00

I have two tables. One has order information with an order id, and the

  • 0

I have two tables. One has order information with an order id, and the other table has order detail information. order_details has multiple rows for each order_id. I’d like a single query that would pull the order information, and then add a ‘column’ for each entry on the order_details table.

Is this possible? And if so, how?

  • 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-28T08:17:03+00:00Added an answer on May 28, 2026 at 8:17 am

    This is not possible in MySQL, or in any SQL that I know of, with the exception of a highly hardcoded query with excessive joins or subqueries.

    This type of problem is typically relegated to the domain of programming languages. If you have an ad-hoc need for a query to do this, then something like this would do it (you will have to quote the keyword order)

    SQL example:

    SELECT 
      order_id, 
      date, 
      (select amt from order_detail where order_id=order.order_id and detail_line=1),
      (select amt from order_detail where order_id=order.order_id and detail_line=2),
      (select amt from order_detail where order_id=order.order_id and detail_line=3),
      (select amt from order_detail where order_id=order.order_id and detail_line=4),
    FROM 
      order
    WHERE 
      order_id = 1234
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables one has a three column composite key. The other needs
I have two tables. One has some product details, the other holds various photos
I have two tables, one that has a foreign key from the other. I
I have a two tables. One has manufacturer information and includes the regions where
I have two tables, one is a table of forum threads. It has a
I have two tables : one table it matchs and the other is teams.
I have two tables, each one has a primary ID column as key. I
Suppose I have two tables that are linked (one has a foreign key to
I have two tables. One (Widgets) has a list of widgets (ID, widget_name, color,
i have two data tables with the same structure the first one has one

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.