Home > Archive > MySQL Server Forum > August 2005 > arcane MySQL db query...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author arcane MySQL db query...
August

2005-08-03, 1:23 pm

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,u
ser_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,u
ser_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,u
ser_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

2005-08-04, 8:23 pm

August wrote:
> INSERT IGNORE INTO mos_comprofiler(id,u
ser_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?


Does this work:

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

Regards,
Bill K.
August

2005-08-05, 3:23 am

Bill Karwin wrote:
> August wrote:
>
>
>
> Does this work:
>
> INSERT IGNORE INTO mos_comprofiler(id,u
ser_id) SELECT user_id,user_id
> FROM "mos_users";
>
> Regards,
> Bill K.

Bill,
Thanks for that - it worked great. I anticipated and error 1054 -
duplicate field, but got no such error. Thanks again!

August
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com