I am listing the records from MySQL, there I consult three tables, users, registers, courses, the table that I show is currently with the users' registers, but with the id of the user I should consult in the table records by the id of the user the course that this has associated, there within the answer to the query of the table records I do a console shown the CodUsuario, my idea is how to compare those records with the users table and thus to know if there exists or not the id of the user in that table, if there is to take the course that has active.
Or the other thing that I think is that I could make a new query to the table records with the id inside the query to the users table, but I do not know how to do it
seintAdmin.controller('adminUsuarios', ['i18nService', 'cargaDatos', '$scope', '$uibModal', function(i18nService, cargaDatos, $scope, $uibModal){
i18nService.setCurrentLang('es');
var salida = this;
var usu = {};
var cur = {};
var reg = {};
salida.datosTabla = {
enableRowSelection: true,
enableSelectAll: false,
multiSelect: false,
enableFiltering: true,
selectionRowHeaderWidth: 24,
rowHeight: 24,
showGridFooter:true,
paginationPageSizes: [100, 200, 500, 1000, 10000],
paginationPageSize: 100,
gridMenuShowHideColumns: false,
columnDefs: [
{name: 'id', visible: false},
{name: 'Nombre', displayName: 'Nombre', enableColumnMenu: false},
{name: 'Cedula', displayName: 'Cédula', enableColumnMenu: false},
{name: 'Empresa', displayName: 'Empresa', enableColumnMenu: false},
{name: 'FechaReg', visible: false},
{name: 'Curso:', displayName: 'Curso:', enableColumnMenu: false}
]
};
cargaTabla();
function cargaTabla() {
cargaDatos.leer('usuarios').then(function(respUsu){
cargaDatos.leer('registros').then(function(respReg){
cargaDatos.leer('cursos').then(function(respCur){
var resp = [];
salida.cursos = respCur;
angular.forEach(respCur, function(valor, llave){
cur[valor.id] = valor.NombreCurso;
});
angular.forEach(respUsu, function(valor, llave){
resp.push({
'id': valor.id,
'Nombre': valor.Nombre,
'Cedula': valor.Cedula,
'Empresa': valor.Empresa,
'FechaReg': valor.FechaReg,
'Curso:': valor.id
});
});
angular.forEach(respReg, function(valor, llave){
reg[valor.id] = valor.CodUsuario;
console.log(reg[valor.CodUsuario]);
});
salida.datosTabla.data = resp;
});
});
});
}