Hi,
When I extract data from two tables which has the same name for columns, it
gives data for only one column.
My tables are employee and department, and their data are as follows,

*Employee*
mysql> select * from employee;
+----+-----------------+---------+--------+
| id | name            | regyear | dep_id |
+----+-----------------+---------+--------+
|  1 | saman kumara    |    2003 |      2 |
|  2 | nimal perera    |    2007 |      1 |
|  3 | kapila kalinkga |    1999 |      3 |
|  4 | sarath senarath |    2010 |      4 |
+----+-----------------+---------+--------+
dep_id represents the id of employee's working department.

*Department*
mysql> select * from department;
+----+-------------+
| id | name        |
+----+-------------+
|  1 | Finance     |
|  2 | Sales       |
|  3 | Engineering |
|  4 | Marketing   |
+----+-------------+

Both tables have a column named "*name*". Now I want all the names of
employees and their attached department names.

My jaggery code for extract data,

<%
var db = new Database("jdbc:mysql://localhost:3306/jagapp", "root",
"mypass");

var result = db.query("SELECT e.name AS ename, d.name AS dname FROM
employee AS e LEFT JOIN department AS d ON e.dep_id = d.id");

print(result);

print("<br>");

for (var i = 0; i < result.length; i++) {
    print(result[i].ename + " : " + result[i].dname + " : " +
result[i].name + "<br>");
}
%>

Result is,

​I cannot get both employee and department names. Any suggestions?
I'm using Jaggery v1.0.0-SNAPSHOT_ALPHA3.
Thanks
-- 
Lalanke Athauda
Software Engineer
Mobile: 0772264301
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to