Solved

How to create this SQL Query?

Posted on 2009-04-09
4
180 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Closing Comment

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

Paul
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

9 Experts available now in Live!

Get 1:1 Help Now