arcane MySQL db query...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • August

    arcane MySQL db query...

    In my continuing attempt to make a user module for my CMS work, I keep
    running into errors with the folowing query, which makes no sense to me
    at all:

    INSERT IGNORE INTO mos_comprofiler (id,user_id) SELECT id,id FROM mos_users";

    where mos_comprofiler is a new parallel User DB and mos_users is the
    original database of users. This first query is supposed to work when
    there is a id column in mos_users. However, my mos_users table has a
    user_id column insted.

    So I then altered the above to read:
    INSERT IGNORE INTO mos_comprofiler (id,user_id) SELECT id,user_id FROM
    mos_users";

    so that it would parse the user-id column instead of id - but it didn't
    work.

    I then ran the following query:
    INSERT IGNORE INTO mos_comprofiler (id,user_id) SELECT id,user_id FROM
    test_users";

    where test_users is a standard table of users with the normal id field.
    The query fails and phpmyadmin says: #1054 - Unknown column 'user_id' in
    'field list'.

    To my eyes, the query doesn't seem to make sense -- or the syntax being
    used is arcane, I'm not sure which. Any ideas how I can make this query
    work for a mos_users table that has the field user_id insted of id?

    August
  • Bill Karwin

    #2
    Re: arcane MySQL db query...

    August wrote:[color=blue]
    > INSERT IGNORE INTO mos_comprofiler (id,user_id) SELECT id,id FROM
    > mos_users";
    > Any ideas how I can make this query
    > work for a mos_users table that has the field user_id insted of id?[/color]

    Does this work:

    INSERT IGNORE INTO mos_comprofiler (id,user_id) SELECT user_id,user_id
    FROM "mos_users" ;

    Regards,
    Bill K.

    Comment

    • August

      #3
      Re: arcane MySQL db query...

      Bill Karwin wrote:[color=blue]
      > August wrote:
      >[color=green]
      >> INSERT IGNORE INTO mos_comprofiler (id,user_id) SELECT id,id FROM
      >> mos_users";
      >> Any ideas how I can make this query work for a mos_users table that
      >> has the field user_id insted of id?[/color]
      >
      >
      > Does this work:
      >
      > INSERT IGNORE INTO mos_comprofiler (id,user_id) SELECT user_id,user_id
      > FROM "mos_users" ;
      >
      > Regards,
      > Bill K.[/color]
      Bill,
      Thanks for that - it worked great. I anticipated and error 1054 -
      duplicate field, but got no such error. Thanks again!

      August

      Comment

      Working...