Home » SQL & PL/SQL » SQL & PL/SQL » help to make sql query (sql)
help to make sql query [message #647239] Sun, 24 January 2016 02:17 Go to next message
deepak416
Messages: 63
Registered: January 2013
Location: Pune
Member
i have a table employee and manager table like below.

EmpId--Name--ManagerId
----------------------
1----- Deep----2 (Employee Id 2 is the manger of employee Deep)
2------Ram-----2
3------Shym----2
4-----Sum------3 (Employee Id 3 is the manger of employee Sum)


I want a result like...

Name------ManagerName
----------------------
Deep------Ram
Ram-------Ram
Shym------Ram
Sum------Shym


when i using below query is showing annoying results. Can you please help.
SELECT name as EmployeeName,(select name from employeerec where `mid`=`empid`) as managerName FROM `employeerec`
Re: help to make sql query [message #647240 is a reply to message #647239] Sun, 24 January 2016 02:26 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
You have been asked (many times) to follow forum etiquette.

Please read our OraFAQ Forum Guide and How to use [code] tags and make your code easier to read

In the mean time, you may want to research the meaning of the term "scalar query", and consider the difference between a literal and a column name.

Re: help to make sql query [message #647244 is a reply to message #647239] Sun, 24 January 2016 03:15 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
deepak416 wrote on Sun, 24 January 2016 08:17
when i using below query is showing annoying results

Strange, when I click on your username and click to view all messages, I also get annoying results.
Re: help to make sql query [message #647255 is a reply to message #647239] Sun, 24 January 2016 07:54 Go to previous message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
Meditate over name resolution in your query. A hint - what table non-qualified column name will be resolved if column with such name exists in multiple tables.

SY.
Previous Topic: Interval Partitioning and local index
Next Topic: Corrections with overlapping time frames (SOLVED)
Goto Forum:
  


Current Time: Fri Apr 26 19:45:34 CDT 2024