Home » SQL & PL/SQL » SQL & PL/SQL » A simple Query (merged)
A simple Query (merged) [message #388292] Tue, 24 February 2009 02:46 Go to next message
saifurshaon
Messages: 29
Registered: December 2007
Location: Dhaka
Junior Member
Hi all,
I am facing a problem which i need to get rid off. I have a view say X. It has four fields. user_id, login_id, name, status, creator_id
Now i am trying to show the creator name which can be found against id. So I write down this query

select a.name USERNAME, a.login_id LOGIN_ID, a.status STATUS, b.name CREATED_BY
from X a, X b
where a.creator_id=b.user_id


But it doesn't work.
Could anyone suggest anything?
Re: A simple Query (merged) [message #388296 is a reply to message #388292] Tue, 24 February 2009 02:55 Go to previous messageGo to next message
Michel Cadot
Messages: 64109
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why it does not work?
Post a Test case: create table and insert statements along with the result you want with these data.

Before please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Re: A simple Query (merged) [message #388297 is a reply to message #388292] Tue, 24 February 2009 02:57 Go to previous messageGo to next message
aviva4500
Messages: 122
Registered: July 2008
Location: bangalore
Senior Member
@saifurshaon,


select a.name USERNAME, a.login_id LOGIN_ID, a.status STATUS, b.name CREATED_BY
from X a, X b
where a.creator_id=b.user_id


Why making join with user_id????

Both Creator_id and User_id have same data???

Follow the guideline of the forum before posting.

Paste the output what you have tried.


Regards,
Hammer

[Updated on: Tue, 24 February 2009 02:58]

Report message to a moderator

Re: A simple Query [message #388299 is a reply to message #388292] Tue, 24 February 2009 02:58 Go to previous message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@saifurshaon,
Please read OraFAQ Forum Guide Please don't multipost your question either.

Quote:

But it doesn't work.


This is not a valid Oracle error message. So the self join didn't work? Prove it by pasting your SQL Plus session here along with the data others asked for.

Regards,
Jo

[Edit: Misread OP's code and removed wrong comments from my side. Apologies...]

[Updated on: Tue, 24 February 2009 03:04]

Report message to a moderator

Previous Topic: Need help in converting LOB to timestamp
Next Topic: sending attachments using smtp
Goto Forum:
  


Current Time: Mon Dec 05 09:15:58 CST 2016

Total time taken to generate the page: 0.05781 seconds