Home » SQL & PL/SQL » SQL & PL/SQL » joining two tables (oracle 11g)
joining two tables [message #583149] Fri, 26 April 2013 05:52 Go to next message
mariomario89
Messages: 5
Registered: April 2013
Junior Member
Hi every one!

I have a table (promo_custom) with following colimns (id, id_promo, button_promo, button_submit, css, user, date)
and other table (promo_buttons) with following columns (id, id_design, name, url, username, date) .

Columns promo_custom.button_promo and promo_custom.button_submit are foreign keys (references promo_buttons.id).

I want to create a view showing table promo_custom but instead of columns button_promo and button_submit I would like to show the column url of them.

Could someone help me with that problem?

Thanks!!
Re: joining two tables [message #583151 is a reply to message #583149] Fri, 26 April 2013 05:56 Go to previous messageGo to next message
Littlefoot
Messages: 19630
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Unless I'm reading it wrong, there's something wrong in your description.

Could you, please, post CREATE TABLE statements for both tables?
Re: joining two tables [message #583152 is a reply to message #583151] Fri, 26 April 2013 06:00 Go to previous messageGo to next message
mariomario89
Messages: 5
Registered: April 2013
Junior Member
I tgive you an example. If button_submit column have data 4, I want the url column of the id 4 of the table promo_buttons
Re: joining two tables [message #583153 is a reply to message #583152] Fri, 26 April 2013 06:03 Go to previous messageGo to next message
Michel Cadot
Messages: 59149
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Littlefoot wrote on Fri, 26 April 2013 12:56
Unless I'm reading it wrong, there's something wrong in your description.

Could you, please, post CREATE TABLE statements for both tables?

Re: joining two tables [message #583156 is a reply to message #583149] Fri, 26 April 2013 06:12 Go to previous messageGo to next message
dariyoosh
Messages: 532
Registered: March 2009
Location: Iran / France
Senior Member
He will not be able to provide a CREATE TABLE statement given the current column names (datatype name, reserved words):

Quote:

I have a table (promo_custom) with following colimns (id, id_promo, button_promo, button_submit, css, user, date)
and other table (promo_buttons) with following columns (id, id_design, name, url, username, date) .



Regards,
Dariyoosh

[Updated on: Fri, 26 April 2013 06:13]

Report message to a moderator

Re: joining two tables [message #583158 is a reply to message #583156] Fri, 26 April 2013 06:18 Go to previous messageGo to next message
Littlefoot
Messages: 19630
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
No kidding. Why do you think we asked for CREATE TABLE statements?
Re: joining two tables [message #583159 is a reply to message #583158] Fri, 26 April 2013 06:20 Go to previous messageGo to next message
dariyoosh
Messages: 532
Registered: March 2009
Location: Iran / France
Senior Member
Littlefoot wrote on Fri, 26 April 2013 13:18
No kidding. Why do you think we asked for CREATE TABLE statements?


The purpose was not kidding just attract the OP's attention to what he was trying to do.


Regards,
Dariyoosh
Re: joining two tables [message #583204 is a reply to message #583159] Sat, 27 April 2013 04:19 Go to previous messageGo to next message
mariomario89
Messages: 5
Registered: April 2013
Junior Member
create table promo_custom ( id number(3) PRIMARY KEY,
id_promo number(3),
buttom_promo number(3),
button_submit number(3),
css number(10),
user varchar2(25),
date date,
constraint buu_pro_fk foreign key(buttom_promo) references promo_buttons(id),
constraint buu_sub_fk foreign key(buttom_submit) references promo_buttons(id));

create table promo_buttons (id number(3) PRIMARY KEY,
id_design number(3),
name varchar2(25),
url varchar2(50),
username varchar2(25),
date date);
Re: joining two tables [message #583205 is a reply to message #583204] Sat, 27 April 2013 04:25 Go to previous messageGo to next message
dariyoosh
Messages: 532
Registered: March 2009
Location: Iran / France
Senior Member
Did you try to run your indicated CREATE TABLE statements and see how oracle reacts?


Regards,
Dariyoosh

[Updated on: Sat, 27 April 2013 04:25]

Report message to a moderator

Re: joining two tables [message #583206 is a reply to message #583205] Sat, 27 April 2013 04:30 Go to previous messageGo to next message
mariomario89
Messages: 5
Registered: April 2013
Junior Member
they reacted ok
Re: joining two tables [message #583207 is a reply to message #583206] Sat, 27 April 2013 04:31 Go to previous messageGo to next message
mariomario89
Messages: 5
Registered: April 2013
Junior Member
I would like to create a view with the as I said .. thanks
Re: joining two tables [message #583208 is a reply to message #583206] Sat, 27 April 2013 04:37 Go to previous message
dariyoosh
Messages: 532
Registered: March 2009
Location: Iran / France
Senior Member
mariomario89 wrote on Sat, 27 April 2013 11:30
they reacted ok


Really??!

Maybe your oracle server is not telling you the truth

SQL> 
create table promo_custom ( id number(3) PRIMARY KEY,
id_promo number(3),
buttom_promo number(3),
button_submit number(3),
css number(10),
user varchar2(25),
date date,
constraint buu_pro_fk foreign key(buttom_promo) references promo_buttons(id),
  9  constraint buu_sub_fk foreign key(buttom_submit) references promo_buttons(id));
user varchar2(25),
*
ERROR at line 6:
ORA-00904: : invalid identifier


SQL> 
SQL> 
SQL> 




Regards,
Dariyoosh
Previous Topic: how to debug package
Next Topic: Required SQL Query Output.
Goto Forum:
  


Current Time: Sun Sep 21 13:28:44 CDT 2014

Total time taken to generate the page: 0.09419 seconds