Solved

select from more than one column mysql

Posted on 2012-03-10
2
539 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 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