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

x
?
Solved

select from more than one column mysql

Posted on 2012-03-10
2
Medium Priority
?
551 Views
Last Modified: 2012-03-10
Is it possible to select from more than one column in sql.
What i am trying to do is build a search where if I type a first name or a last name in my search form I can retrieve data checking two different columns.  Is that possible.  This code does not work but it may give you an idea of what I am trying to do.  I want to look in mem_first_name or mem_last_name and retrieve all that match my search.

"SELECT * FROM members WHERE mem_first_name = %s OR mem_last_name = %s"

Open in new window

0
Comment
Question by:Luey
[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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 37705719
that kind of query should actually work.
so, the question is:
what error do you get, actually?
how exactly do you fill in the search string into %s ?
0
 

Author Closing Comment

by:Luey
ID: 37705729
I thought it would to.  I did it a different way and it worked as well.
Thanks for you help.
"SELECT * FROM members WHERE mem_first_name = '$search_name' OR mem_last_name = '$search_name'";
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The viewer will learn how to count occurrences of each item in an array.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

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