Fórum Dúvida Select com 2 tabelas #430688
07/12/2012
0
Nome Cliente ( Lookup do codcliente da tabela cliente )
Data
Hora
Situação
Como eu não tenho o nome do cliente na tabela Agenda, eu fiquei meio confuso em fazer a consulta.
Fiz dessa forma mas não ta retornando nenhum registro:
qryAgenda.SQL.Add('select * from tblAgenda,tblCliente where ' +
'tblAgenda.codcliente = tblCliente.cliente like ' +
#39 + (edtPesquisa.Text) + '%' + #39);
Estou usando o MySQL.
Grato.
Vander Carlos
Curtir tópico
+ 0Posts
07/12/2012
Elizeu Outros
Eu acho que esta faltando um and ai no seu select...
Anterior
qryAgenda.SQL.Add('select * from tblAgenda,tblCliente where ' +
'tblAgenda.codcliente = tblCliente.cliente like ' +
#39 + (edtPesquisa.Text) + '%' + #39);
qryAgenda.SQL.Add('select * from tblAgenda,tblCliente where ' +
'tblAgenda.codcliente = tblCliente.codcliente and tblCliente.NomeCliente like ' +
#39 + (edtPesquisa.Text) + '%' + #39);
Espero ter ajudado...
Gostei + 0
08/12/2012
Samuel Lopes
Agenda (codcliente(fk)para tabela cliente,data,hora,situacao);
Cliente (codcliente(pk),nome_cliente...)
Então acredito que funcione da seguinte forma:
qryAgenda.SQL.Add('select a.*,c.nome_cliente from tblAgenda A, tblCliente c');
qryAgenda.SQL.Add('where c.nome_cliente like '''+edtPesquisa.Text+'''% AND a.codcliente=c.codcliente');
Gostei + 0
08/12/2012
Samuel Lopes
Agenda (codcliente(fk)para tabela cliente,data,hora,situacao);
Cliente (codcliente(pk),nome_cliente...)
Então acredito que funcione da seguinte forma:
qryAgenda.SQL.Add('select a.*,c.nome_cliente from tblAgenda a, tblCliente c');
qryAgenda.SQL.Add('where c.nome_cliente like '''+edtPesquisa.Text+'''% AND a.codcliente=c.codcliente');
Gostei + 0
10/12/2012
Vander Carlos
Muito Obrigado =)
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)