Solved

select from more than one column mysql

Posted on 2012-03-10
2
537 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
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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