-1
Good afternoon. I want to make an Internet but the result does not come out.
Tabela1 = rec Campo = chvbfj(3) <- codigo do cliente
Tabela1 = rec Campo = doc(3,4,5) <- lista de codigos de itens do cliente
Tabela2 = vndB Campo = chvvnda(3,4,5) <- tem o codigo de itens do cliente
Tabela2 = vndB Campo = chvps(1,1,2) <- codigo da descrição
Tabela3 = ps Campo = chvps(1,1,2) <- tem o codigo da descrição
Tabela3 = ps Campo = Desc(escova, escola, lixa) <- descricao do codigo
Making the client’s query(3) he lists the items(1,1,2), but would have to appear the code description(brush, brush, sandpaper).
public DataTable PesquisaResumo(global::CamadaModelos.mdlEmpresa _mdlEmpresa)
{
string ConexaoAccess = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\tabela.mdb";
OleDbConnection ConexaoDB = new OleDbConnection(ConexaoAccess);
ConexaoDB.Open();
string Query = "SELECT rec.chvbfj, rec.doc, vndB.chvvnda, vndB.chvps, ps.chvps, ps.Dsc FROM rec INNER JOIN vndB on vndB.chvvnda = rec.doc INNER JOIN ps on ps.chvps = vndB.chvps WHERE rec.chvbfj = @id";
OleDbCommand cmd = new OleDbCommand(Query, ConexaoDB);
cmd.CommandType = CommandType.Text;
OleDbParameter pmtID = cmd.CreateParameter();
pmtID.ParameterName = "@id";
pmtID.DbType = DbType.String;
pmtID.Value = _mdlEmpresa.ID;
cmd.Parameters.Add(pmtID);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable empresas = new DataTable();
da.Fill(empresas);
ConexaoDB.Close();
return empresas;
}
How is your current query?
– bfavaretto
select chvbfj, doc from rec Where chvbfj=@id
– Thiago Mazette
This link may be useful to you: https://www.devmedia.com.br/utilizando-joins-em-sql/1071
– Ronaldo Araújo Alves
in your sql TA THUS
vndB.chvps, ps.chvps,
can not have two repeated names strip 1 of them– novic
except either one or both of the error. (operator missing)
– Thiago Mazette
then I’ll change the SQL pera ae
– novic
try that one:
SELECT rec.chvbfj, rec.doc, vndB.chvvnda, vndB.chvps, ps.Desc FROM vndB 
 INNER JOIN rec ON vndB.chvvnda = rec.doc
 INNER JOIN ps ON vndB.chvps = ps.chvps
WHERE rec.chvbfj = 3
– novic
'Syntax error (missing operator) in query expression 'vndB.chvvnda = rec.doc INNER JOIN ps ON vndB.chvps = ps.chvps'.'
– Thiago Mazette
Next Thiago the error is in the tables, there is no way we test the way to do it is so expensive has no where, this can be mixed data, this can be so much, it is a local problem.
– novic
It looks like you are using Microsoft Access. I believe it requires you to place parentheses when using multiple Join.
– anonimo