/    Sign up×
Community /Pin to ProfileBookmark

search database in multiple rows

Hi,

is there a way to search the database in multiple rows?
this is the most common way:

[code=php]
SELECT * FROM content WHERE titel LIKE ‘%”.$keyword.”%’;[/code]

But i don’t want to search row “titel” only i also want row “naam”

[code=php]
SELECT * FROM content WHERE titel LIKE ‘%”.$keyword.”%’;[/code]

[code=php]
SELECT * FROM content WHERE naamLIKE ‘%”.$keyword.”%’;[/code]

How can this be done??

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 19.2006 — <i>
</i>SELECT * FROM table_name WHERE col1 LIKE '%value1%' AND col2 LIKE '%value2%'

You can change the "AND" to an "OR" depending on what logic you want.
Copy linkTweet thisAlerts:
@zebdaagauthorJun 19.2006 — owkay works great,

i only thought of one thing...is it possible to order the search result??

something like
[code=php]SELECT * FROM table_name WHERE col1 LIKE '%value1%' AND col2 LIKE '%value2%' LIMIT 0,30 ORDER BY date DESC[/code]
Copy linkTweet thisAlerts:
@bathurst_guyJun 19.2006 — Usually it is easier just to try things rather than post it and wait for a response,

but to respond to your question I don't see why it wouldn't work like that.
Copy linkTweet thisAlerts:
@NogDogJun 19.2006 — I believe the LIMIT clause would come last (after the ORDER BY clause).
×

Success!

Help @zebdaag spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...