One Star

Join by SQL Statement

Hi,
I want to join 2 tables and filter the data according to some rules.
I already have the sql statement for this operation from my colleague.
So, is there anyway I can directly use this sql statement to join and filter the data from these 2 tables?
or do I have to use tMap to put in the conditions?
Please reply ASAP..
Thank You.
Kyaw Lwin Phyo
12 REPLIES
Community Manager

Re: Join by SQL Statement

Hi
You can use txxxRow such as tMysqlRow the execute the sql statement if the sql statement have already achieved the request join two table and filter data. Or use a tMap to do the join and add filter condition to filter the data.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Join by SQL Statement

Hi Shong,
Thanks for the fast response...
What kinda txxxRow should I use?
My input is from oracle and output is to MySQL.
Thanks again...
Kyaw Lwin Phyo
Community Manager

Re: Join by SQL Statement

Hi
Please use tMap component and create the general job if the input and output tables are in different database type.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: Join by SQL Statement

You can put any select statement you want in your input component (join, group by, where, order by, nested) as long as the schema you define is consistent with the result of the query.
One Star

Re: Join by SQL Statement

Hello...
I have put a query in tMySqlInput component and direct this component to tMap.
but in tMap, the result from my query is not there but the standard columns from the table.
My table has Year, Week, Month, Start Date, End Date columns
and my query returns the concated value of YearWeek-Start DateEnd Date as period.
However, in tMap, I'm only seeing the columns but not my returned value.
I've tried with tMySqlRow too.
I need this period variable to validate the data from another table which I need to join.
Any Suggestion????
Thank you.
Kyaw Lwin Phyo
Community Manager

Re: Join by SQL Statement

Hi
Please upload some screenshots of job or show us an example to explain your request, so that we could help you further.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: Join by SQL Statement

Put up a screenshot of your job and the tMySqlInput settings, particularly the query and schema
One Star

Re: Join by SQL Statement

Did you do a guess schema for your query?
One Star

Re: Join by SQL Statement

I have uploaded the screenshots
First one is how I'm trying to do.
I have one table that has data and another weeks table which has the dates
I have to filter the data from first table with the dates from weeks table.
Second one is my query.
In fact the full query is like
getting the period value below to check the local_date of the table.
"SELECT concat(w.year, w.week, date_format(w.`Start Date`, '%d-%b-%Y'), date_format(w.`End Date`, '%d-%b-%Y')) period
FROM calendar.weeks w
WHERE date_sub(curdate(), interval 7 day) >= w.`Start Date`
AND date_sub(curdate(), interval 7 day) <= w.`End Date`; => period = 20113604-Sep-201110-Sep-2011"
Third one is how I'm getting in tMap.
Thank You.....
(if images are not available please also tell me how to upload images..
I've tried from the link http://www.talendforge.org/forum/viewtopic.php?id=831)
Seven Stars

Re: Join by SQL Statement

As you say, your SQL is returning a single column only (the concated value of YearWeek-Start DateEnd Date) but the schema for the component has the standard columns from the table. Change the schema to match the results of the query. That is why there is a warning icon against the component.
One Star

Re: Join by SQL Statement

Hi,
I want to join 2 tables and filter the data according to some rules.
I already have the sql statement for this operation from my colleague.
So, is there anyway I can directly use this sql statement to join and filter the data from these 2 tables?
or do I have to use tMap to put in the conditions?
Please reply ASAP..
Thank You.
Kyaw Lwin Phyo

SQL application is also prone to corruption like an other application. It may get corrupted or damaged due to various reasons. SQL become damaged due to virus attck, power failure or due to improper shut down. When SQL database become corrupted it becomes impossible for SQL user to make join statement. It needs My SQL repair
One Star

Re: Join by SQL Statement

You need to edit the schema from your query to reflect what is being returned. It looks as though you just have a default table schema defined.