Consulta em SQL (codigo não deu certo)
Como eu faço uma consulta em SQL, as vagas que estão LIVRE entre dois números:
Que seja >=1 e <=10
..........Exemplo..........
edit1.text:= ‘1&8217;
edit2.text:= &8216;10&8217;
edit3.text:= &8216;LIVRE&8217;
ou seja vou digita 1 e 10 e LIVRE nos edit ........ Click no Botão consulta e sair o Resultado das Vagas entre o Número 1 e 10 que esteja LIVRE...............O que eu coloco na Propriedade SQL da Query ...... e no Events Onclick do Botão Consulta ? Agradeço Jairo-GO
[b:c5666d0f58].................Me Passaram este codigo abaixo mas não deu CERTO........[/b:c5666d0f58]
SQL (QryConsulta):
Código:
SELECT * FROM TABELA
WHERE (NUMERO BETWEEN :NUMI AND :NUMF)
AND SITUACAO = :SITUACAO
OnClick:
Código:
QryConsulta.ParamByName(´NUMI´).Value := Edit1.Text;
QryConsulta.ParamByName(´NUMF´).Value := Edit2.Text;
QryConsulta.ParamByName(´SITUACAO´).Value := Edit3.Text;
QryConsulta.Open;
Que seja >=1 e <=10
..........Exemplo..........
edit1.text:= ‘1&8217;
edit2.text:= &8216;10&8217;
edit3.text:= &8216;LIVRE&8217;
ou seja vou digita 1 e 10 e LIVRE nos edit ........ Click no Botão consulta e sair o Resultado das Vagas entre o Número 1 e 10 que esteja LIVRE...............O que eu coloco na Propriedade SQL da Query ...... e no Events Onclick do Botão Consulta ? Agradeço Jairo-GO
[b:c5666d0f58].................Me Passaram este codigo abaixo mas não deu CERTO........[/b:c5666d0f58]
SQL (QryConsulta):
Código:
SELECT * FROM TABELA
WHERE (NUMERO BETWEEN :NUMI AND :NUMF)
AND SITUACAO = :SITUACAO
OnClick:
Código:
QryConsulta.ParamByName(´NUMI´).Value := Edit1.Text;
QryConsulta.ParamByName(´NUMF´).Value := Edit2.Text;
QryConsulta.ParamByName(´SITUACAO´).Value := Edit3.Text;
QryConsulta.Open;
Jairo-go
Curtidas 0
Respostas
Hatrix
31/10/2003
SQL (QryConsulta):
Código:
SELECT * FROM TABELA
WHERE (NUMERO BETWEEN :NUMI AND :NUMF)
AND SITUACAO = :SITUACAO
OnClick:
Código:
QryConsulta.ParamByName(´NUMI´).Value := Edit1.Text;
QryConsulta.ParamByName(´NUMF´).Value := Edit2.Text;
QryConsulta.ParamByName(´SITUACAO´).Value := Edit3.Text;
QryConsulta.Open;
A sintaxe não está errada, mas tente usar a mesma, c/ apenas algumas modificações:
Código:
SELECT * FROM TABELA
WHERE (NUMERO BETWEEN :NUMI AND :NUMF)
AND UPPER(SITUACAO) = UPPER(:SITUACAO )
OnClick:
Código:
QryConsulta.ParamByName(´NUMI´).AsInteger := StrToInt(Edit1.Text);
QryConsulta.ParamByName(´NUMF´).AsInteger := StrToInt(Edit2.Text);
QryConsulta.ParamByName(´SITUACAO´).AsString := Trim(Edit3.Text);
QryConsulta.Open;
Código:
SELECT * FROM TABELA
WHERE (NUMERO BETWEEN :NUMI AND :NUMF)
AND SITUACAO = :SITUACAO
OnClick:
Código:
QryConsulta.ParamByName(´NUMI´).Value := Edit1.Text;
QryConsulta.ParamByName(´NUMF´).Value := Edit2.Text;
QryConsulta.ParamByName(´SITUACAO´).Value := Edit3.Text;
QryConsulta.Open;
A sintaxe não está errada, mas tente usar a mesma, c/ apenas algumas modificações:
Código:
SELECT * FROM TABELA
WHERE (NUMERO BETWEEN :NUMI AND :NUMF)
AND UPPER(SITUACAO) = UPPER(:SITUACAO )
OnClick:
Código:
QryConsulta.ParamByName(´NUMI´).AsInteger := StrToInt(Edit1.Text);
QryConsulta.ParamByName(´NUMF´).AsInteger := StrToInt(Edit2.Text);
QryConsulta.ParamByName(´SITUACAO´).AsString := Trim(Edit3.Text);
QryConsulta.Open;
GOSTEI 0
Edkardoso
31/10/2003
dica: Use o access para construir seus SQL. Faça lá sua consulta, depois visualize e copie o SQL. Fica muito mais fácil.
SQL * FROM tabela/query where (vaga >=1 AND <=1) and situacao=´LIVRE´
Espero que isto tenha ajudado. Caso contrário tente o access, tenho certeza que vc vai conseguir.
Um abraço.
SQL * FROM tabela/query where (vaga >=1 AND <=1) and situacao=´LIVRE´
Espero que isto tenha ajudado. Caso contrário tente o access, tenho certeza que vc vai conseguir.
Um abraço.
GOSTEI 0