Solved

Mysql where clause in visual c++

Posted on 2004-09-29
2
361 Views
Last Modified: 2012-05-05
Hi,
I have a program in visual c++ .net that connects to a remote Mysql server.
Everything works just fine, I only have a problem when I execute a Mysql query to retrive data:

if I use the following it works just fine

            format = _T("SELECT * FROM clienti WHERE Client_code LIKE '%s'");

            sql.Format(format,m_searchString);

if I try to use this:

            format = _T("SELECT * FROM clienti WHERE Client_code  LIKE '%s' || Name LIKE '%s'");

            sql.Format(format,m_searchString);

where I only added "OR" to wide the search, either gives no result at all or only gives results of the first where clause "Client_code  LIKE '%s' "

I wonder if I need a special syntax to implement "OR" and "AND" statement in visual c++ .net and libmySQL.

Do you have any ideas??

thanks rik

0
Comment
Question by:rcinformatica
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 500 total points
ID: 12178792
If you change || to OR, it should give you the proper results:
format = _T("SELECT * FROM clienti WHERE Client_code  LIKE '%s' OR Name LIKE '%s'");
Plus, there's a problem with your Format call. You're only giving it one variable to match one %s; you need a variable for each %s.
sql.Format(format,m_searchString, m_searchString);

Hope this helps.
0
 

Author Comment

by:rcinformatica
ID: 12179101
exactly what I needed thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now