I have requirement where i will fetch where condition stored in other table which can be like id > 10 or amount < 100.
I am using Stored Procedure to perform some task in which i am retrieving this where condition and using it to insert some data into table. But it's not working maybe due to apostrophe is being appended at front and end.
set @whereC = (select FilterCondition from SearchLeads where `SearchLeadID` = sid);
INSERT INTO `JTemporary` 
        (`ZipID`,`FirstName`,`LastName`,`MemberSince`,
        `Address1`,`Phone`,`Email`,`CompanyName`,
        `BusPhone`,`Deleted`,`CreatedBy`,`CreateDate`,
        `UpdatedBy`,`UpdateDate`)
  select `ZipCode`,`FirstName`,`LastName`,`AddDate`,
        `AddressLine1`,`HomePhone`,`HomeEmail`,`Employer`,
        `BusinessPhone`,'N',loginUserID,now(),
        loginUserID,now() 
    from membertrans where @whereC;
This isn't working. When i apply directly by copying that condition and putting in place of variable it works, But doesn't work with variable.
How to achieve this?
 
     
     
    