[filter-fodder: sql, query]

Hi,

I am having trouble finding differences.
Table1 holds the current data, and Table2 holds the updates.
I need to query the two and find ONLY the rows showing the current+updates.

Table1:
TABLE dttunes (
id smallint(5) unsigned NOT NULL auto_increment, 
danceid smallint(5) unsigned NOT NULL default '0', 
ddref smallint(5) unsigned NOT NULL default '0', 
tuneid smallint(5) unsigned NOT NULL default '0', 
tkey smallint(5) unsigned NOT NULL default '0', 
tname varchar(100) NOT NULL default '', 

Table2:
TABLE ddtunes (
id smallint(5) unsigned NOT NULL auto_increment, 
ddref smallint(5) unsigned NOT NULL default '0', 
tkey smallint(5) unsigned NOT NULL default '0', 
tname varchar(100) NOT NULL default '',

This query:
select dttunes.*, ddtunes.*
from dttunes left join ddtunes on (dttunes.tkey=ddtunes.tkey and 
dttunes.tname=ddtunes.tname)
where dttunes.ddref=ddtunes.ddref and dttunes.danceid=5688;

returns this:
| danceid | ddref | tuneid | tkey | tname                          
|    5688 |  5829 |    140 |  156 | Bonnie Lass o' Bon Accord, The 
|    5688 |  5829 |   1493 | 1613 | Singing Bird, The              

| ddref | tkey | tname                          |
|  5829 |  156 | Bonnie Lass o' Bon Accord, The |
|  5829 | 1613 | Singing Bird, The              

BUT I only want it to return rows in the event of a different tune being 
assigned to a dance, ie. where dttunes.ddref != ddtunes.ddref

It's hard. I have failed so far.  Can anyone help?

Donna































---------------------------------------------------------------------
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

Reply via email to