Solved

How to create this SQL Query?

Posted on 2009-04-09
4
199 Views
Last Modified: 2012-05-06
Hi Folks,

I want to Query the database (3 fields)  and find all matches for a particular word. I want to search both the name, website and the category field for this word.

Example:

If I query for the word jenna it shoudl return all records of which either the name, website or category contains the word jenna.

If you need more info please ask. Im using phpMyAdmin

Regards Dweep

Ps a next step will be to convert this into php code and use a textbox so the user can search the database for whatever word he wants and get the results displayed.
SELECT *
FROM `adressen`
WHERE `name` = "jenna"

Open in new window

0
Comment
Question by:PeterdeB
  • 2
4 Comments
 
LVL 6

Expert Comment

by:twocandles
ID: 24105935
try this:


SELECT *
FROM `adressen`
WHERE `name` like "jenna"
or 'website' like "jenna"
or 'category' like "jenna"

Open in new window

0
 
LVL 14

Accepted Solution

by:
shobinsun earned 500 total points
ID: 24106024
Hello,

use:

SELECT * FROM `adressen` WHERE `name` like "%jenna%" or 'website' like "%jenna%" or category' like "%jenna%"

Its more correct.

Regards.
0
 
LVL 14

Expert Comment

by:shobinsun
ID: 24106039
0
 

Author Closing Comment

by:PeterdeB
ID: 31568457
Exactly what I asked for thanks a lot! Some more questions will follow regarding this project.

Paul
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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