Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
MySQL: WHERE fieldname = multiple values
Old 02-27-2009, 02:33 PM MySQL: WHERE fieldname = multiple values
Average Talker

Posts: 19
Trades: 0
I've been trying to do this for a while, searched all over the Googlenet for the answer and have come up with nothing.

There are certain sections of my site where I only want to display MySQL entries that correspond with two or more possible values of a field. That sounds really convoluted, so I'll just write up what I have.

Code:
$queryRecordset = "SELECT * FROM tablename WHERE fieldname=('value_a' || 'value_b' || 'value_c')";
Obviously, this isn't working. I've tried replacing || with && and commas, as well as with and without brackets. I'm not the most skilled with MySQL syntax, so I'm just working with what I know. Any help would be immensely appreciated.
Kent O'Matic is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-27-2009, 03:22 PM Re: MySQL: WHERE fieldname = multiple values
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
WHERE fieldname = 'value' OR fieldname = 'value2' ...
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-27-2009, 03:35 PM Re: MySQL: WHERE fieldname = multiple values
Average Talker

Posts: 19
Trades: 0
GAH! I swear I already tried that and it didn't work. Either way, it's working now. Thanks muchos bunchesos.
Kent O'Matic is offline
Reply With Quote
View Public Profile
 
Old 02-27-2009, 04:52 PM Re: MySQL: WHERE fieldname = multiple values
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
More readable, in my opinion, is the in() operator
Code:
SELECT * 
FROM tablename 
WHERE fieldname in('value_a', 'value_b', 'value_c')
But in the end, it's the same than using OR keywords.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to MySQL: WHERE fieldname = multiple values
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12986 seconds with 12 queries