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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:26:41+00:00 2026-05-17T17:26:41+00:00

Current query : SELECT order_id AS OrderNumber, ordName, ordLastName, question, answer FROM cart_survey JOIN

  • 0

Current query:

SELECT order_id AS OrderNumber, ordName, ordLastName, question, answer 
FROM cart_survey 
JOIN orders 
    ON cart_survey.order_id=orders.ordID 
JOIN survey_answers 
    ON survey_answers.id=cart_survey.answer_id 
JOIN survey_questions 
    ON survey_questions.id=cart_survey.question_id

Results:

OrderNumber ordName ordLastName question                        answer
8591        Larry   Marshburn   Type of Surgery:                Colostomy  
8591        Larry   Marshburn   Month of Surgery:               2
8591        Larry   Marshburn   Year of surgery:                2010
8591        Larry   Marshburn   Current Ostomy System Brand:    ConvaTec  
8591        Larry   Marshburn   Degree of Satisfaction:         Somewhat Satisfied  
8593        Melvin  Belcher     Type of Surgery:                Urostomy
8593        Melvin  Belcher     Month of Surgery:               9
8593        Melvin  Belcher     Year of surgery:                2010
8593        Melvin  Belcher     Current Ostomy System Brand:    ConvaTec  
8593        Melvin  Belcher     Degree of Satisfaction:         Very Satisfied  

How do I properly query the tables to pull results that will look like this?
Name and Lastname on a single line and questions for columns and answers for each column.

Desired Results

OrderNumber ordName ordLastName "Type of Surgery" "Month of Surgery" "Year of Surgery" etc.
8591        Larry   Marshbourn   Colostomy         2                  2010
8593        Melvin  Belcher      Urostomy          9                  2010
  • 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-17T17:26:41+00:00Added an answer on May 17, 2026 at 5:26 pm

    This is the MSSQL Version

    select o.*, q1.[Type of Surgery:], q2.[Month of Surgery:], q3.[Year of surgery:]
        , q4.[Current Ostomy System Brand:]
        , q5.[Degree of Satisfaction with the fit and comfort of your Current Ostomy System:]
    from (
        select distinct ordID, ordName + ' ' + ordLastName as [name] from dbo.Orders
    ) o
    left join (
        select *, a.[Answer] as [Type of Surgery:] from cart_survey cs
        left join dbo.survey_answers a on cs.answer_id = a.id
        where cs.question_id = 1
    ) q1 on o.ordID = q1.[order_id]
    left join (
        select *, a.[Answer] as [Month of Surgery:] from cart_survey cs
        left join dbo.survey_answers a on cs.answer_id = a.id
        where cs.question_id = 2
    ) q2 on o.ordID = q2.[order_id]
    left join (
        select *, a.[Answer] as [Year of surgery:] from cart_survey cs
        left join dbo.survey_answers a on cs.answer_id = a.id
        where cs.question_id = 3
    ) q3 on o.ordID = q3.[order_id]
    left join (
        select *, a.[Answer] as [Current Brand:] from cart_survey cs
        left join dbo.survey_answers a on cs.answer_id = a.id
        where cs.question_id = 4
    ) q4 on o.ordID = q4.[order_id]
    left join (
        select *, a.[Answer] as [Degree of Satisfaction:] from cart_survey cs
        left join dbo.survey_answers a on cs.answer_id = a.id
        where cs.question_id = 5
    ) q5 on o.ordID = q5.[order_id]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current query reads: SELECT entry_id, user_id, cat_id, AVG( rating ) as avg_rate FROM
My Current query is: SELECT DISTINCT DATE(vote_timestamp) AS Date, COUNT(*) AS TotalVotes FROM `votes`
Quick question if anyone has time to answer. The current query works great, but
with my current query and loop: $sched = mysql_query(SELECT * FROM `shows` ORDER BY
This is an example version of my current SQL query: SELECT DISTINCT files.* FROM
Current Query: SELECT DISTINCT HSP.HSP_ACCOUNT_ID, HSP.HSP_ACCOUNT_NAME, HSP.ADM_DATE_TIME, HSP.DISCH_DATE_TIME, HSP.TOT_CHGS, HSP_ACCT_MULT_DRGS.DRG_ID_TYPE_ID, HSP_ACCT_MULT_DRGS.DRG_MPI_CODE FROM C.HSP HSP
the current SQL query works fine locally on MAMP 1.8.4 running MySQL 5.1.37. SELECT
Here is the updated question: the current query is doing something like: $sql1 =
Is is possible to query the current browser from within an applet? I would
I'm trying to get the query string from a string (not the current URL).

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.