I'm no expert in this in fact I just recently started playing with
joins, but here's one that I actually used for a recent shopprt cart
piece. I appologise if it wraps but the output is long...content
conatins the basic content info but product contains the list of prices.
Yes I could have just as easily put the price in the content tbl, but I
wanted the admin to pull the predefined prices from one source and make
a selectable option rather than a type in value. I also figured from a
maintenance standpoint when the price goes up it's one change etc... Ok
so in any even I joined the two tbls on c.product_id and p.id. If I read
you question correctly you should be able to perform smething similar on
eventlog.id and crossref.id...
mysql select c.*, p.cost from content as c, product as p where
c.product_id = p.id ;
++-+-+---+--++-+--+
| id | filename| thumbnail | sdescr|
ldescr | product_id | publish | cost |
++-+-+---+--++-+--+
| 3 | sample.mov | OCSLogo.png | Silly Apple Comercial | came with
the streaming server. | 1 | y | 5.95 |
| 1 | sample2.mov | OCSLogo.png | Silly Apple Comercial | came with
the streaming server. | 2 | y | 2.95 |
| 2 | sample.mov | OCSLogo.png | Silly Apple Comercial | came with
the streaming server. | 2 | y | 2.95 |
++-+-+---+--++-+--+
3 rows in set (0.00 sec)
I hope this helps...
cheers,
Mikel
Jaime Teng wrote:
Hi,
I have two tables:
mysql describe eventlog;
+-+--+--+-+-++
| Field | Type | Null | Key | Default | Extra |
+-+--+--+-+-++
| id | int(10) unsigned | | PRI | NULL| auto_increment |
| timestamp | int(10) unsigned | | MUL | 0 ||
| description | char(100)| | MUL | ||
+-+--+--+-+-++
mysql describe crossref;
+-+--+--+-+-++
| Field | Type | Null | Key | Default | Extra |
+-+--+--+-+-++
| word| char(20) | | MUL | ||
| id | int(10) unsigned | | MUL | ||
+-+--+--+-+-++
Table 'eventlog' is a table of sentence and a unique 'id'. Table crossref
is simply a table of single words and an index 'id'. an entry contains a
word and an id where said word can be found on the table 'eventlog'.
It is common that a: SELECT * from crossref where word = 'HELLO'; would
have multiple results.
My question here is I would like to do a search wherein I would like
to know which sentence contains the words 'HELLO' and 'DAY' and 'WORLD'.
take note that the sentence SHOULD contain ALL the three words not just
one or two.
I think this is a 'JOIN' question but I am not familiar how to use JOIN.
can you show me the syntax?
thanks for your help.
Jaime
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php