Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-25-2006, 07:13 PM
Bill Karwin
 
Posts: n/a
Default Re: Finding data that is _not_ on 2 tables?

"Simon" <spambucket@example.com> wrote in message
news:48l482Fkfi7jU1@individual.net...
> Hi,
>
> I have 2 tables, TABLE_A and TABLE_B
> Both table have a "user_name" section.
>
> I want to run a con job from time to time that would add "user_name" from
> TABLE_A if it does not already exist on TABLE_B.
> How would I run such an update?
>
> The select would look something like...
> Select "user_name" from TABLE_A where "user_name" not in TABLE_B


I'm not sure I understand what you want to do. Do you want to SELECT
entries from table_A that do not occur in table_B? Do you want to INSERT
records to either table? Do you want to UPDATE a record in table_A? By
"user_name," do you mean a literal string, or a column named user_name?

Just going on a guess, here's a query that shows values in the user_name
column of TABLE_A that do not occur in TABLE_B.

SELECT A.user_name
FROM TABLE_A AS A
LEFT OUTER JOIN TABLE_B AS B ON A.user_name = B.user_name
WHERE B.user_name IS NULL

> But "NOT IN" does not seem to be valid, (MySQL 4).


I know what you mean, but for what it's worth, NOT IN is valid in any
version of MySQL.
That is, you can do "NOT IN (1,2,3)" in any version.
However, subqueries are not supported in MySQL 4.0.

Regards,
Bill K.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:23 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.