How should I modify the query to select all records, the subquery returned a single value for each tuple?

I have a query that works fine provided that the table has only one entry:

SELECT Waybill.Id
, Waybill.IMO
Vessel.Name
, Waybill.loginManager
User.Name
, Waybill.loginStorekeeper
, (SELECT DISTINCT(Name) FROM User WHERE Waybill (Waybill.loginStorekeeper = User.login)) AS storekeeperName
, Waybill.Date 
FROM Waybill, Vessel, User 
WHERE Waybill.IMO = Vessel.IMO
AND Waybill.loginManager = User.Login
AND Waybill.loginManager = User.Login
ORDER BY Waybill.Id


However, if records are more than one, then the subquery returns multiple values, causing the error. Can you please tell me how to fix the query?

Thanks in advance.
April 3rd 20 at 18:36
1 answer
April 3rd 20 at 18:38
Solution
The subquery is inserted in the list of columns must vozrasti only ONE row.
or rewrite the subquery to it in any case return only one row, or golite him or the table.
Additionally, the subquery is not tied to the tables of the sample ?? so and think?

what is the General relationship between tables what is the table? what should be the result of the sample?

Wang, that must be something like this:

SELECT
w.Id
w.IMO
v.Name
w.loginManager
 ,um.Name AS managerName
w.loginStorekeeper
 ,umk.Name AS storekeeperName
 w.Date 
 FROM Waybill w
 INNER JOIN Vessel v ON w.IMO = v.IMO
 INNER JOIN User ON um w.loginManager = um.Login
 INNER JOIN User ON umk w.loginStorekeeper = umk.Login
 ORDER BY w.Id
Thank you very much for the help! You will excuse me for my ignorance of the language, I only recently started my acquaintance with him. - Brayan_Moore98 commented on April 3rd 20 at 18:41

Find more questions by tags SQL