• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Updating table with query of 2 other tables?

Guest
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

Greetings

I apologize in advance if this seems too easy to do- but I am missing something.

I have 8000 records in an Access DB (I know- it's going into SQL soon) in which all  the departmental office IDs need to be updated.

The column in the main table  is named "q_office_ID".

The user table includes  user_ID &  office_ID.

The office table also includes office_ID.

This UPDATE sets all the values to the number 10?:

<cfquery name="update" datasource="#Request.BaseDSN#">

SELECT     queue_ID, q_user_ID, user_ID, office_ID

FROM     main_helpdesk, lookup_user

WHERE  q_user_ID = user_ID

</cfquery>

<cfloop query="update"><cfquery name="updatedata" datasource="#Request.BaseDSN#">

UPDATE main_helpdesk

SET q_office_ID = #office_ID#

</cfquery></cfloop>

I know there is something obviously wrong with the update- any help would be greatly appreciated.

Thank You

TOPICS
Database access

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

The lack of a where clause is pretty significant.    

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

Dan

Whether I missed something as obvious as that or I already tried the "where" clause I guess is not clear- but I only asked because I tried it many different ways with no good result.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

Actually, it was:

<cfquery name="update" datasource="#Request.BaseDSN#">

SELECT queue_ID, q_user_ID, user_ID, office_ID

FROM main_helpdesk, lookup_user

</cfquery>

<cfloop query="update">

<cfquery name="updatedata" datasource="#Request.BaseDSN#">

UPDATE main_helpdesk

SET q_office_ID = #office_ID#

WHERE q_user_ID = #user_ID#

</cfquery></cfloop>

My mistake.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

LATEST

Did you ever try a single query?  This page describes how to do it.  http://www.techonthenet.com/access/queries/update2.php

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation