PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > query for two different values from one field
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
query for two different values from one field

Réponse
 
LinkBack Outils de la discussion
Vieux 28/03/2008, 16h40   #1
canajien@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut query for two different values from one field

I have a field that stores one of three possible answers: yes, no,
maybe

and I know that if I write:

SELECT *
FROM table
WHERE field = "yes"

I will get all the records where the field = yes, but how do I get it
to return all the records when the field equal yes or maybe

thanks
  Réponse avec citation
Vieux 28/03/2008, 16h45   #2
Erick T. Barkhuis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field

canajien@gmail.com:
> I have a field that stores one of three possible answers: yes, no,
> maybe
>
> and I know that if I write:
>
> SELECT *
> FROM table
> WHERE field = "yes"
>
> I will get all the records where the field = yes, but how do I get it
> to return all the records when the field equal yes or maybe


SELECT *
FROM table
WHERE field = "theFemaleAnswer"

--
Erick
[scnr]
  Réponse avec citation
Vieux 28/03/2008, 17h03   #3
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field

On Fri, 28 Mar 2008 08:40:51 -0700 (PDT), canajien@gmail.com wrote:
> I have a field that stores one of three possible answers: yes, no,
> maybe
>
> and I know that if I write:
>
> SELECT *
> FROM table
> WHERE field = "yes"
>
> I will get all the records where the field = yes, but how do I get it
> to return all the records when the field equal yes or maybe


Look up the logical construct "OR" in combination with SELECT.

We hope you get an A on your quiz.

--
58. If it becomes necessary to escape, I will never stop to pose dramatically
and toss off a one-liner.
--Peter Anspach's list of things to do as an Evil Overlord
  Réponse avec citation
Vieux 28/03/2008, 17h38   #4
canajien@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field

On Mar 28, 12:03 pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Fri, 28 Mar 2008 08:40:51 -0700 (PDT), canaj...@gmail.com wrote:
> > I have a field that stores one of three possible answers: yes, no,
> > maybe

>
> > and I know that if I write:

>
> > SELECT *
> > FROM table
> > WHERE field = "yes"

>
> > I will get all the records where the field = yes, but how do I get it
> > to return all the records when the field equal yes or maybe

>
> Look up the logical construct "OR" in combination with SELECT.
>
> We hope you get an A on your quiz.
>
> --
> 58. If it becomes necessary to escape, I will never stop to pose dramatically
> and toss off a one-liner.
> --Peter Anspach's list of things to do as an Evil Overlord


i already tried that

SELECT *
FROM table
WHERE field = "yes"
OR field = "no"

and it didn't work

however I did a search on your hint and I read that I can use
brackets, so when I wrote it as:

SELECT *
FROM table
(WHERE field = "yes"
OR field = "no")

it did work, don't ask me why.

BTW it's not a quiz I am just bored at work today so I thought I would
brush up on a few things...

Thanks for the information it got me pointed in the right direction!!!
  Réponse avec citation
Vieux 28/03/2008, 21h48   #5
ThanksButNo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field

On Mar 28, 8:40 am, "canaj...@gmail.com" <canaj...@gmail.com> wrote:
> I have a field that stores one of three possible answers: yes, no,
> maybe
>
> and I know that if I write:
>
> SELECT *
> FROM table
> WHERE field = "yes"
>
> I will get all the records where the field = yes, but how do I get it
> to return all the records when the field equal yes or maybe
>
> thanks


SELECT *
FROM table
WHERE field IN ('yes', 'maybe')
  Réponse avec citation
Vieux 28/03/2008, 21h50   #6
ThanksButNo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field

On Mar 28, 8:45 am, Erick T. Barkhuis <erick.use-...@ardane.c-o-m>
wrote:
> canaj...@gmail.com:
>
> > I have a field that stores one of three possible answers: yes, no,
> > maybe

>
> > and I know that if I write:

>
> > SELECT *
> > FROM table
> > WHERE field = "yes"

>
> > I will get all the records where the field = yes, but how do I get it
> > to return all the records when the field equal yes or maybe

>
> SELECT *
> FROM table
> WHERE field = "theFemaleAnswer"
>
> --
> Erick
> [scnr]


No no no -- that would either return ALL records, or SOME of the
records, in a non-deterministic (but not random) fashion.
  Réponse avec citation
Vieux 29/03/2008, 18h53   #7
log4work
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field

I suggest to check:

SELECT *
FROM table
WHERE field IN ('YES', 'MAYBE', 'yes', 'maybe');

You can try to use some functions like upper, lower. Check what exactly is
inside your column and rows.


Uzytkownik "ThanksButNo" <no.no.thanks@gmail.com> napisal w wiadomosci
news:79a584ca-df4a-45f3-af80-f7030f38931c@s8g2000prg.googlegroups.com...
> On Mar 28, 8:40 am, "canaj...@gmail.com" <canaj...@gmail.com> wrote:
>> I have a field that stores one of three possible answers: yes, no,
>> maybe
>>
>> and I know that if I write:
>>
>> SELECT *
>> FROM table
>> WHERE field = "yes"
>>
>> I will get all the records where the field = yes, but how do I get it
>> to return all the records when the field equal yes or maybe
>>
>> thanks

>
> SELECT *
> FROM table
> WHERE field IN ('yes', 'maybe')



  Réponse avec citation
Vieux 29/03/2008, 18h55   #8
log4work
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field


Uzytkownik "ThanksButNo" <no.no.thanks@gmail.com> napisal w wiadomosci
news:79a584ca-df4a-45f3-af80-f7030f38931c@s8g2000prg.googlegroups.com...
> On Mar 28, 8:40 am, "canaj...@gmail.com" <canaj...@gmail.com> wrote:
>> I have a field that stores one of three possible answers: yes, no,
>> maybe
>>
>> and I know that if I write:
>>
>> SELECT *
>> FROM table
>> WHERE field = "yes"
>>
>> I will get all the records where the field = yes, but how do I get it
>> to return all the records when the field equal yes or maybe
>>
>> thanks

>
> SELECT *
> FROM table
> WHERE field IN ('yes', 'maybe')



I suggest to check:

SELECT *
FROM table
WHERE field IN ('YES', 'MAYBE', 'yes', 'maybe');

You can try to use some functions like upper, lower. Check what exactly is
inside your column and rows.


  Réponse avec citation
Vieux 29/03/2008, 20h43   #9
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query for two different values from one field

log4work wrote:
> Uzytkownik "ThanksButNo" <no.no.thanks@gmail.com> napisal w wiadomosci
> news:79a584ca-df4a-45f3-af80-f7030f38931c@s8g2000prg.googlegroups.com...
>> On Mar 28, 8:40 am, "canaj...@gmail.com" <canaj...@gmail.com> wrote:
>>> I have a field that stores one of three possible answers: yes, no,
>>> maybe
>>>
>>> and I know that if I write:
>>>
>>> SELECT *
>>> FROM table
>>> WHERE field = "yes"
>>>
>>> I will get all the records where the field = yes, but how do I get it
>>> to return all the records when the field equal yes or maybe
>>>
>>> thanks

>> SELECT *
>> FROM table
>> WHERE field IN ('yes', 'maybe')

>
>
> I suggest to check:
>
> SELECT *
> FROM table
> WHERE field IN ('YES', 'MAYBE', 'yes', 'maybe');
>
> You can try to use some functions like upper, lower. Check what exactly is
> inside your column and rows.
>
>
>


Unnecessary, if this is character (non-binary) data. Comparisons are
case-insensitive.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h28.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16446 seconds with 17 queries