[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql-developer
Subject: RE: Stuck on "or" query
From: "Neulinger, Nathan R." <nneul () umr ! edu>
Date: 1999-05-04 16:26:30
[Download RAW message or body]
You've got an open-ended query.
See below.
------------------------------------------------------------
Nathan Neulinger EMail: nneul@umr.edu
University of Missouri - Rolla Phone: (573) 341-4841
Computing Services Fax: (573) 341-4216
> -----Original Message-----
> From: Jeff Schwartz [mailto:Jeff@SuperCalendar.com]
> Sent: Monday, May 03, 1999 8:27 PM
> To: developer@lists.mysql.com
> Subject: Stuck on "or" query
>
>
> I'm trying to combine the results of 2 different searches:
>
> "select * from stickers, members where members.user='$user' and
> (members.is_owner='Y' or members.is_editor='Y') and
> stickers.category='Group' and stickers.s_user=group_id"
>
> and:
>
> "select * from stickers where stickers.s_user='$user'"
You're only selecting from one table here.
>
> combined to:
>
> "select * from stickers, members where (members.user='$user' and
> (members.is_owner='Y' or members.is_editor='Y') and
> stickers.category='Group' and stickers.s_user=members.group_id) or
> stickers.s_user='$user'"
You either need to do something like:
(stickers.s_user='$user' and stickers.s_user=members.user)
or do an outer join.
Probably the way to write the query would be:
select * from stickers, members where
(
(members.is_owner='Y' or members.is_editor='Y')
and members.user='$user'
and stickers.category='Group'
and stickers.s_user=members.group_id
)
or
(
stickers.s_user='$user'"
and members.s_user=stickers.s_user
)
But based on your comments below, that may not do what you need - in which
case, you'll need an outer join.
>
> The first query returns 4 records, the second 1, so I should get 5
> total. Yet, when I combine them I get thousands of records. I
> believe I
> understand why but I can't seems to fix the query. What am I doing
> wrong?
>
> Also, I don't need any data from the members table, I'm just
> using it to
> qualify records from the stickers table. But if I don't select records
> from it I get an error. Is there a way to use a table in the select
> criteria but not return records from it?
>
> Thanks,
> Jeff
> --
> SuperCalendar highlights your calendar with color and stickers.
> Create your free SuperCalendar today!
>
> ---------------------------------------------------------------------
> Please check
"http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail developer-thread34@lists.mysql.com
To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail developer-unsubscribe@lists.mysql.com instead.
---------------------------------------------------------------------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail developer-thread36@lists.mysql.com
To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail developer-unsubscribe@lists.mysql.com instead.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic