beginner81
Programmer
I want to check whether a certain record is exists in database or not using the parameter CustName and Product(which is the value that pass from other form).
I'd write the SQL stament as following :
function TDataModule.IsExists(CustName: String; Product:String): Boolean;
begin
with qry do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM CUSTOMER AS A1 INNER JOIN PRODUCT AS A2 ON A1.CUSTOMER_ID=A2.CUSTOMERID');
SQL.Add('WHERE CustName=:CUstName');
SQL.Add('AND Product=roduct');
ParamByName('CustName').AsString := CustName;
ParamByName('Product').AsString := Product;
Open;
result := not IsEmpty;
end;
end;
CUSTOMER and PRODUCT is different table, so i think i need to use the joint statement(correct me if i'm wrong)..
But the code is seems like not working correctly .. can anyone help me find out the problem ?? is the way i use the
Join statement correct ?? Hope can hear from ya guys soon.. and thx in advance for ya help..
I'd write the SQL stament as following :
function TDataModule.IsExists(CustName: String; Product:String): Boolean;
begin
with qry do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM CUSTOMER AS A1 INNER JOIN PRODUCT AS A2 ON A1.CUSTOMER_ID=A2.CUSTOMERID');
SQL.Add('WHERE CustName=:CUstName');
SQL.Add('AND Product=roduct');
ParamByName('CustName').AsString := CustName;
ParamByName('Product').AsString := Product;
Open;
result := not IsEmpty;
end;
end;
CUSTOMER and PRODUCT is different table, so i think i need to use the joint statement(correct me if i'm wrong)..
But the code is seems like not working correctly .. can anyone help me find out the problem ?? is the way i use the
Join statement correct ?? Hope can hear from ya guys soon.. and thx in advance for ya help..