This is a discussion on query for two different values from one field within the MySQL Database forums, part of the Database Forums category; I have a field that stores one of three possible answers: yes, no, maybe and I know that if I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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] |
|
|||
|
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 |
|
|||
|
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!!! |
|
|||
|
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') |
|
|||
|
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. |
|
|||
|
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') |
|
|||
|
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. |
|
|||
|
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 ================== |
![]() |
| Thread Tools | |
| Display Modes | |
|
|