Find rows in table A where table B = 'hello' AND table B = 'world'

2006-06-19 Thread David Otton
That's a lousy subject line, but I don't know how to describe this problem. 
I've been banging my head against this for a couple of days, and I'm certain 
there's a simple solution I'm missing.

I've got a URL table, a keyword table, and a joining table, so each URL has a 
list of keywords applied to it, and each keyword can be applied to many URLs:

tbl_url
---

INT urlid,
VARCHAR url

tbl_keyword
---

INT keywordid,
VARCHAR keyword

tbl_url_keyword
---

INT urlid,
INT keywordid

How do I find all the tags that are tagged with the words mysql AND 
databases AND tutorial?

It seems so simple, I can't believe it's caused me so much grief.



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Replication, Windows, Modems

2004-08-16 Thread David Otton
Hi, hoping someone's come across this before:

I need to replicate data between two copies of MySQL, both running on
Windows XP.

The amount of data is tiny - maybe 35k a day as an upper bound. It's
basically monitoring data from a remote device.

The problem is that neither machine is internet-enabled - they both
have modems in them.

So, what's the best way to run this sequence several times a day?

a) connect to the remote machine via modem
b) kick off the MySQL replication process

I'm thinking a small VB app, but any pointers gratefully received.
Google hasn't thrown up much of use, and Windows administration isn't
really my thing.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Missing row

2003-07-29 Thread David Otton
Hi, small but disturbing oddity, this.

I have a simple table:

CREATE TABLE musician (
musicianid int(10) unsigned NOT NULL auto_increment,
name varchar(60) NOT NULL default '',
PRIMARY KEY (musicianid)
) Type=MyISAM;

There are 50 or so lines in the table. I inserted 2 new lines with PHP, with
this statement:

INSERT INTO musician SET name = '$name'

But from the console, one of the lines is missing:

mysql SELECT * FROM musician ORDER BY musicianid;

+++
| musicianid | name   |
+++
[...]
| 51 | Jewel  |
| 52 | Lush   |
| 53 | My Bloody Valentine|
| 55 | Fred   |
+++

Yet if I ask for the missing line specifically, it is there:

mysql SELECT * FROM musician WHERE musicianid = 54;

+++
| musicianid | name   |
+++
| 54 | john Smith |
+++

Restarting the console doesn't seem to make any difference (I haven't tried
restarting MySQL). Is this expected behaviour? A bug?

My system:
mysql  Ver 11.16 Distrib 3.23.49, for Win95/Win98 (i32)
Apache/1.3.24 (Win32)
PHP Version 4.3.2


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Select where A is not a member of B

2001-09-10 Thread David Otton

Hi - I've got an annoying problem here, I've checked books, web,
archives, etc, but can't find anything suitable so far.

I have 2 data tables (ignoring the other columns, not important) :

++
|   user |
++
| userid |
++

++
|   list |
++
| listid |
++

and a joining table :

+--+
| userlist |
+--+
|   listid |
|   userid |
+--+

As you can see, users can belong to many lists, lists can contain many
users.

I need to find, for each user, whether they are a member of list n :

++--+
| userid | memberoflist |
++--+
|  1 | true |
|  2 |false |
|  3 | true |
|  4 |false |
++--+

It seems simple, but I've been banging my head against this all
weekend. When I break it down, I need to find 3 things :

Users that are members :

SELECT user.userid FROM user, userlist WHERE listid=1 AND
user.userid=userlist.userid

Users that belong to NO lists :

SELECT user.userid FROM user LEFT JOIN userlist ON
user.userid=userlist.userid WHERE listid IS NULL

Users that belong to some lists, but not the one I'm interested in :
this is the one that I'm stuck on. Any thoughts? Suggestions?

djo


-
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