I have a database with two tables. One is a list of our web pages, and the other is a list of topics for our website. This database was cobbled together over a number of years, and it started off serving a totally different purpose than it serves now.
Right now, the tables are joined by the two text columns (page_topic = topic_name) which is not ideal. I’ve created a new topic ID column in the web page table that I want to use instead, but I need to populate that table with the ID from the topics table.
I’ve tried all three of these to no avail:
UPDATE webpages
SET webpages.topic_id = ( SELECT topics.topic_id
FROM topics
WHERE topics.topic_name = webpages.page_topic )
WHERE webpages.page_topic = topics.topic_name
UPDATE webpages
SET topic_id = topics.topic_id
FROM webpages
INNER JOIN topics
ON webpages.page_topic = topics.topic_name
WHERE page_topic = topic_name
UPDATE webpages
SET webpages.topic_id = topics.topic_id
FROM webpages, topics
WHERE webpages.page_topic = topics.topic_name
Either I’m on the wrong track, or this is an Access idiosyncrasy. Anyone know which?
and if that doesn’t work, try this, which is your first query with a different WHERE clause
UPDATE webpages
SET webpages.topic_id =
( SELECT topics.topic_id
FROM topics
WHERE topics.topic_name = webpages.page_topic )
WHERE EXISTS
( SELECT topics.topic_id
FROM topics
WHERE topics.topic_name = webpages.page_topic )
Thanks rudy. That gives me the all too familiar "[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query. " error.
I might just have to query the topics, and stick an update query in the <cfoutput> tags and make a loop.