Home » SQL & PL/SQL » SQL & PL/SQL » Query Help (Oracle 11g)
Query Help [message #567710] Thu, 04 October 2012 08:20 Go to next message
UZUMAKI
Messages: 7
Registered: October 2012
Junior Member
Hello,

I have to make a query, and I'm with some difficulties. How do I get these 3 in one query?

Select id_grupo from adm_util_grupos where id_utilizador=1;
Select id_menu from adm_grupos_menus where id_grupo=1;
select etiqueta from adm_menus where id_menu=1;

He liked to help

[Updated on: Thu, 04 October 2012 08:21]

Report message to a moderator

Re: Query Help [message #567711 is a reply to message #567710] Thu, 04 October 2012 08:25 Go to previous messageGo to next message
Michel Cadot
Messages: 59405
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
On one line with 3 columns or on one column and 3 lines?

With any SQL question, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
Re: Query Help [message #567713 is a reply to message #567711] Thu, 04 October 2012 08:27 Go to previous messageGo to next message
Michel Cadot
Messages: 59405
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
First option:
select id_grupo, id_menu, etiqueta
from 
(Select id_grupo from adm_util_grupos where id_utilizador=1),
(Select id_menu from adm_grupos_menus where id_grupo=1),
(select etiqueta from adm_menus where id_menu=1)
/

Second option:
Select id_grupo from adm_util_grupos where id_utilizador=1
union all 
Select id_menu from adm_grupos_menus where id_grupo=1
union all 
select etiqueta from adm_menus where id_menu=1
/

Regards
Michel
Re: Query Help [message #567714 is a reply to message #567713] Thu, 04 October 2012 08:32 Go to previous messageGo to next message
UZUMAKI
Messages: 7
Registered: October 2012
Junior Member
I explained myself badly. The id_utilizador is the only thing that I take, other reactions come select the first result of the select. Am I making myself clear?

[Updated on: Thu, 04 October 2012 08:35]

Report message to a moderator

Re: Query Help [message #567715 is a reply to message #567714] Thu, 04 October 2012 08:38 Go to previous messageGo to next message
Michel Cadot
Messages: 59405
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
No it is not clear.

Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Regards
Michel
Re: Query Help [message #567716 is a reply to message #567715] Thu, 04 October 2012 08:40 Go to previous messageGo to next message
Michel Cadot
Messages: 59405
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Or do you mean:
select etiqueta from adm_menus 
where id_menu in (
  Select id_menu from adm_grupos_menus 
  where id_grupo in (
    Select id_grupo from adm_util_grupos where id_utilizador=1
    )
  )
/

Regards
Michel
Re: Query Help [message #567717 is a reply to message #567716] Thu, 04 October 2012 08:45 Go to previous message
UZUMAKI
Messages: 7
Registered: October 2012
Junior Member
He was here to write a history you see fit for my difficulty xD That's right. Thank you and excuse my bad explanation
Previous Topic: Error in creating Materialized view
Next Topic: regexp_like
Goto Forum:
  


Current Time: Mon Oct 20 20:49:17 CDT 2014

Total time taken to generate the page: 0.09243 seconds