List:General Discussion« Previous MessageNext Message »
From:<sinisa Date:March 19 1999 1:04am
Subject:SQL Question??: Using Join in Update
View as plain text  
Brandon Shuey writes:
 > I am running mySQL under NT4.0.
 > I am trying a simple update statement that does a left join and updates on null
values.  The exact same join works in a select
 > statement but will not work in a update statement.  I get the following error:
 > ERROR 1064 at line1: parse error near 'LEFT JOIN table2 ON table1.ID=table2.Field'
 > 
 > This is the select statement that works correctly:
 > SELECT table1.* FROM table1
 > LEFT JOIN table2 ON(table1.ID = table2.Field)
 > WHERE (((table2.Field) is NULL))
 > 
 > Here is the update that doesn't work:
 > UPDATE table1
 > LEFT JOIN table2 ON table1.ID = table2.Field
 > SET table1.ID = "Invalid"
 > WHERE (((table2.Field) Is Null));
 > 
 > The documentation does not address joins in Update queries so I do believe this is a
valid question.
 > Brandon Shuey
 > WebCentric Inc.
 > (316) 612-8030
 > brandon@stripped
 > 
 > 

Hi!

Joins are used only in SELECT.

Sinisa

+---------------------------------------------------------------------+
| TcX  ____  __     _____   _____  ___        ==  mysql@stripped        |
|     /*/\*\/\*\   /*/ \*\ /*/ \*\ |*|        Sinisa Milivojevic      |
|    /*/ /*/ /*/   \*\_   |*|   |*||*|        mailto:sinisa@stripped |
|   /*/ /*/ /*/\*\/*/  \*\|*|   |*||*|        Belgrade                |
|  /*/     /*/  /*/\*\_/*/ \*\_/*/ |*|_____   Serbia                  |
|  ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^                           |
|             /*/             \*\                   Developers Team   |
+---------------------------------------------------------------------+
Thread
SQL Question??: Using Join in Update(Brandon Shuey)18 Mar
  • SQL Question??: Using Join in Updatesinisa19 Mar
  • SQL Question??: Using Join in UpdateMichael Widenius19 Mar