[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


MYSQL OR Statement Help

Posted on 2008-06-11
Medium Priority
Last Modified: 2013-12-13
$query = "select * from vendor where (businessname OR primarycontact OR estimatingcontact OR ownerofficercontact) like \"%$trimmed%\" order by businessname"; // EDIT HERE and specify your table and field names for the SQL query

I am new to using OR statements.
Is my syntax above correct, its returning no results.
If I do just businessname, I have results.
Question by:digarati
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
LVL 19

Accepted Solution

elimesika earned 200 total points
ID: 21760105

No, it is not correct , see code
 $query = "select * from vendor where (businessname like \"%$trimmed%\" OR primarycontact like \"%$trimmed%\" OR estimatingcontact like \"%$trimmed%\" OR like \"%$trimmed%\" ownerofficercontact) order by businessname"; // EDIT HERE and specify your table and field names for the SQL query

Open in new window

LVL 24

Assisted Solution

purplepomegranite earned 200 total points
ID: 21760110
You need to apply the condition to each field, as attached.
 $query = "select * from vendor where (businessname  like \"%$trimmed%\") OR (primarycontact  like \"%$trimmed%\") OR (estimatingcontact like \"%$trimmed%\") OR (ownerofficercontact like \"%$trimmed%\") order by businessname";

Open in new window


Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

650 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