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

  • Home
  • SEARCH
  • 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 8819983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:29:53+00:00 2026-06-14T05:29:53+00:00

Here is my sp query: — ——————————————————————————– — Routine DDL — Note: comments before

  • 0

Here is my sp query:

  -- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`%` PROCEDURE `USP_GetUserOrders`(UserId INT)
BEGIN
SELECT op.OrderId,
    O.Number,    
    SUM(op.Price) Price,
    (SELECT CONCAT(A.Detail, ' ',C.Name, ' / ', Ci.Name) FROM kobiakinlar.Address AS A
                INNER JOIN County AS C ON C.CountyId = A.CountyId
                INNER JOIN City AS Ci ON C.CityId = Ci.CityId
                WHERE UserId = O.UserId) AS UserAddress,
   ( SELECT CASE WHEN O.Status =0 THEN 'Onay Bekliyor'  WHEN O.Status =1 THEN 'Onaylandı' WHEN O.Status = 2 THEN 'Reddedildi' END) Status,
    O.Creation,
    ( SELECT CASE WHEN O.IsDelivered =0 THEN 'Teslim Edilmedi' ELSE 'Teslim Edildi' END) IsDelivered,
    group_concat(P.Name) Product
FROM
    kobiakinlar.product P
        JOIN
    kobiakinlar.orderproduct op ON op.ProductId = P.productId
        JOIN
    kobiakinlar.order O ON O.orderId = op.OrderId
   JOIN 
kobiakinlar.address A ON A.addressId = O.AddressId
WHERE O.UserId = UserId
GROUP BY op.OrderId;
END

It returns Error Code: 1242. Subquery returns more than 1 row when I CALL USP_GetUserOrders(3)

But I run only sql in query tab, it runs and return what I want. You can see query’s result in image:

enter image description here

Do you have any suggestion?

  • 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-14T05:29:54+00:00Added an answer on June 14, 2026 at 5:29 am

    I’m pretty sure the reason is the confusion between UserId and o.UserId.

    In the query context, it does not know that you mean the argument to the sp. Change the name of the arguemnt to something like “arg_UserId” and substitute that in the query where appropriate.

    You can also simplify your query syntax. The SELECT outside the case statements is redundant. Also, assuming that the joins to County and City are always 1-1, you can rewrite the query as:

    SELECT op.OrderId, O.Number,  SUM(op.Price) Price,
           CONCAT(A.Detail, ' ', C.Name, ' / ', Ci.Name) AS UserAddress,
           (CASE WHEN O.Status =0 THEN 'Onay Bekliyor'  WHEN O.Status =1 THEN 'Onaylandı' WHEN O.Status = 2 THEN 'Reddedildi' END) Status,
           O.Creation,
           (CASE WHEN O.IsDelivered =0 THEN 'Teslim Edilmedi' ELSE 'Teslim Edildi' END) IsDelivered,
           group_concat(P.Name) as Product
    FROM kobiakinlar.product P JOIN
         kobiakinlar.orderproduct op
         ON op.ProductId = P.productId JOIN
         kobiakinlar.order O
         ON O.orderId = op.OrderId JOIN 
         kobiakinlar.address A ON A.addressId = O.AddressId join
         County C
         ON C.CountyId = A.CountyId join
         City AS Ci
         ON C.CityId = Ci.CityId
    WHERE O.UserId = arg_UserId
    GROUP BY op.OrderId;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm doing a simple query here and it returns that column 'Mary' does not
No coffee. Brain. Not. Functioning. I have this linq query here: Public Function ListAllVisitDates()
I have a query here regarding the value given to the update attribute of
I'm stuck with another coordinates related query here. I have a number of CSV
I can't figure out what I am doing wrong with my query here. SELECT
Here is my query (I replaced table names with generic ones). I am trying
Here's my query SELECT * FROM wp_postmeta WHERE meta_value LIKE '.$_POST['username'].' AND meta_value LIKE
Here is original Query :, it generates o/p with two columns name (label, count)
Here's the query I'm trying to convert into Linq: SELECT R.Code, R.FlightNumber, S.[Date], S.Station,
Here's the query: SELECT COUNT(*) AS c, MAX(`followers_count`) AS max_fc, MIN(`followers_count`) AS min_fc, MAX(`following_count`)

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.