If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Unable to Update Using Inner Join

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-16-03, 10:44
rlwright10 rlwright10 is offline
Registered User
 
Join Date: Nov 2003
Posts: 1
Unable to Update Using Inner Join

I'm trying to update 1 table using a join to link data from another table:

Table 1: products

products_id int(5)
products_quantity int(4)
products_model varchar(12)
products_image varchar(64)
products_mediumimage varchar(64)
products_largeimage varchar(64)
products_price decimal(15,4)
products_date_products_weight decimal(5,2)
products_status tinyint(1)
products_tax_class_id int(5)
manufacturers_id int(5)
products_date_available datetime
products_last_modified datetime
products_ordered int(11)


Table 2: products_to_categories

products_id int(5)
products_id int(5)


Failing SQL Statement:

update products
inner join products_to_categories on
products_to_categories.products_id = products.products_id
set products.products_image = 'CS-D9.jpg'
where products_to_categories.categories_id = 63;

Error:

You have an error in your SQL syntax near 'INNER JOIN products_to_categories ON products_to_categories.products_id = produ' at line 1
Reply With Quote
  #2 (permalink)  
Old 11-16-03, 16:08
Dylan Leblanc Dylan Leblanc is offline
Registered User
 
Join Date: May 2002
Location: Vancouver Canada
Posts: 26
I don't think you can do joins in updates with MySQL yet
Reply With Quote
  #3 (permalink)  
Old 11-17-03, 04:24
pthoff pthoff is offline
Registered User
 
Join Date: Apr 2003
Location: Norway
Posts: 5
Wink

Try this:

update products
set products.products_image = 'CS-D9.jpg'
from products inner join products_to_categories on
products_to_categories.products_id = products.products_id
where products_to_categories.categories_id = 63;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On