MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 17th, 2000, 08:29 AM
sosed sosed is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Hadera, Israel
Posts: 1 sosed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi!

I have the following table structure
on which I want to perform "smart"
queries:

+-------------------+------------ ------+
| Field | Type |
+-------------------+-------------------+
| login | varchar(8) |
| keyword | varchar(25) |
+-------------------+-------------------+

The table contains users and keywords,
associated with them.
Any user can have multiple keywords,
and, any keyword can belong to multiple
users. I.e. there could be multiple rows
with the same "login" field value,
and multiple rows with the same "keyword"
field value. Thus, there's no primary key
in this table.

Now, I need to perform some "smart"
queries on this table, like select
all the users having "keyword x" OR
"keyword y" OR ... etc.
With "OR" it works fine.
But when it comes to "AND" - I'm in
trouble. Cause the same row cannot have
both "keyword x" AND "keyword y" at the
same time. So the query result is always
empty.

Any ideas on how I can perform a "smart"
query on this kind of a table?

Actually, what I really want is to be able
to enter a more complicated query
like "x OR (y AND NOT (m OR n))".

I'm entering the query in an edit box
(I have a web-based database interface),
and, since the "WHERE" clause can have
the same complexity (or, and , not,
brackets), I want to enter that query
"as is" into the "WHERE" clause of the
"SELECT" statement (with only minor changes,
like adding "keyword =" for every keyword
entered in the query (in the edit box)).

Any ideas?

Thanks in advance,

sosed.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > A "smart" SQL query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT