Log in

View Full Version : SQL query with 2 differenet table



parscon
07-08-2015, 11:49 PM
Hello , I have Table with this column



Table1 has columns (ID, Name, TEXTTYPE , LANGID) and sample data:
(1, John, RB, 11),
(2, Peter, PM, 12),
(3, Mary, RB, 11)
(4, Kristina, RB, 11)
Table2 has columns (TEXTTYPE , LANGID , Description, TRANSLATE) and sample data:
(RB , 11, Apple, FR),
(PM, 12, Apricot, GB),
(RB , 14, Aubergine, TR),
(PM, 12, Orange, FR),
(RB, 11, Banana, GB)


I need The below result only Show FR value in TRANSLATE column:

(1, John, RB, 11 , Apple),
(2, Peter, PM, 12, Orange),
(3, Mary, RB, 11, Apple),
(4, Kristina, RB, 11, Apple)

I need this query for Oracle.

Tommy
07-10-2015, 07:40 AM
As long as there is duplicate information in the tables your query will always return information that you may not want.

(RB , 11, Apple, FR), <--- Same as last line
(PM, 12, Apricot, GB), <---- Same as 4th line
(RB , 14, Aubergine, TR),
(PM, 12, Orange, FR), <--- Same as second line
(RB, 11, Banana, GB) <---- Same as first line

Select table1.ID, table1.Name, table1.texttype table1.langid inner join table2.langid, table2.description

The above query may have the inner join incorrect but it is a start, I do not have Oracle to test it with.

stanl
07-29-2015, 05:07 AM
Need to do a subselect. Assuming the fields TEXTTYPE, LANGID are distinct -