Expecting duplicate row with different output in the last column.
Here's my Stored Procedure query
SELECT
Name = SELECT ......
Mobile = SELECT .....
Title = SELECT .....
Developer = (SELECT Description FROM ParameterDeveloper WHERE Id IN (SELECT WorkId FROM Company WHERE Id = Records.ApplicationId)
FROM Records
Here's my Records Table
ApplicationId | Name |
---|---|
100 | Sky |
300 | Sam |
400 | Luke |
Here's my ParameterDeveloper Table
Id | Description |
---|---|
100 | Oracle |
100 | Ibm |
200 | Salesforce |
Here's my Company Table
Id | WorkId |
---|---|
100 | 100 |
200 | 200 |
300 | 300 |
Expected result -
Name | Developer |
---|---|
Sky | Oracle |
Sky | Ibm |
My Error is:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
CodePudding user response:
your data
CREATE TABLE Records (
ApplicationId INTEGER NOT NULL
,Name VARCHAR(100) NOT NULL
);
INSERT INTO Records
(ApplicationId,Name) VALUES
(100,'Sky'),
(300,'Sam'),
(400,'Luke');
CREATE TABLE ParameterDeveloper (
Id INTEGER NOT NULL
,Description VARCHAR(100) NOT NULL
);
INSERT INTO ParameterDeveloper
(Id,Description) VALUES
(100,'Oracle'),
(100,'Ibm'),
(200,'Salesforce');
CREATE TABLE Company (
Id INTEGER NOT NULL
,WorkId INTEGER NOT NULL
);
INSERT INTO Company
(Id,WorkId) VALUES
(100,100),
(200,200),
(300,300);
your query
select Name,Description
from Records R
JOIN Company C
ON C.Id=R.ApplicationId
JOIN ParameterDeveloper P
ON P.Id=R.ApplicationId