Administer > Database Administration > Data persistence > Queries > Cross-table join query improvements > Example: Handle two files that have the same field name

Example: Handle two files that have the same field name

This query finds all open incidents for which your department is the service owner of the affected service, and then prints the category of the incidents and the category of the service.

Note If two fields have same name, you must use an alias to distinguish the fields.

var file = new SCFile("probsummary");
var sql = "select p.*,d.category AS cate from probsummary p LEFT OUTER JOIN device d ON (p.affected.item=d.logical.name) where d.owner=$lo.dept and p.flag=true";
var success = file.doSelect(sql);

print(file.category);
print(file.cate);