How to rephase statement for use in SQL from MS Access in Delphi

I have a statement that is being used for MS Access in Delphi. However, as I need to upgrade the database to SQL, I am not sure how to reconstruct the statement. The statement that is being used for MS Access is:

SQL.Add('Select * From table1, table2 Where field1 Like ' + ' "' + Text1.text + '*' + '" ');

The statement run when a entry is entered into the text box and it will look up the SQL database and show only the refined results.

Any help is appreciated.
 
LVL 1
cwtangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcsentinelCommented:
Just Replace the * with a % sign

so

the SQL ends up looking like


 SELECT * FROM table1 WHERE Field1 LIKE "Fred%"
To find all instances starting with Fred

or

 SELECT * FROM table1 WHERE Field1 LIKE "%Fred%"
To find all instances containing Fred

or

 SELECT * FROM table1 WHERE Field1 LIKE "%Fred"
To find all instances ending in Fred

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mohammed NasmanSoftware DeveloperCommented:
as pcsentinel said, replace * with %

also you need to correct the quoations in your statement

so your statement will look like

SQL.Add('Select * From table1, table2 Where field1 Like ' + QuotedStr(Text1.text + '%');
0
saravananvgCommented:
Hello sir,

  it should be as follows

SQL.Add('Select * from table1,table2 where Field1 like '''+Text1.Text+'%''');

with regards,
padmaja.
0
cwtangAuthor Commented:
Thanks everyone. Got it working :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.