Professional Web Applications Themes

Finding data that is _not_ on 2 tables? - MySQL

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 But "NOT IN" does not seem to be valid, (MySQL 4). Many thanks. Simon...

  1. #1

    Default Finding data that is _not_ on 2 tables?

    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

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

    Many thanks.

    Simon


    Simon Guest

  2. #2

    Default Re: Finding data that is _not_ on 2 tables?

    "Simon" <spambucketexample.com> wrote in message
    news:48l482Fkfi7jU1individual.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.


    Bill Karwin Guest

Similar Threads

  1. Finding data files in local directory
    By Xopods in forum Macromedia Flex General Discussion
    Replies: 3
    Last Post: April 9th, 05:17 AM
  2. Please help with data in 2 tables
    By Vivista Eastbourne in forum ASP Database
    Replies: 10
    Last Post: October 13th, 02:07 PM
  3. Finding non-printing characters in data
    By Laurie Gustin in forum Informix
    Replies: 1
    Last Post: July 29th, 08:56 PM
  4. Finding Specific Data
    By Antonio in forum Microsoft Access
    Replies: 2
    Last Post: July 14th, 02:52 PM
  5. Replies: 1
    Last Post: July 10th, 08:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139