Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mysql where clause in visual c++

Posted on 2004-09-29
2
Medium Priority
?
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

715 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