RE: UPDATE question, SQL syntax, etc.

2002-05-20 Thread Jay Blanchard

[snip]
update trackinfo SET trackinfo.postcode = newtrackinfo.postcode FROM
trackinfo, newtrackinfo WHERE trackinfo.telephone = newtrackinfo.telephone;
[/snip]

http://www.mysql.com/doc/U/P/UPDATE.html
MySQL does not support sub-queries, such as the one you are attempting here.
(the FROM on..) You could try INSERT...SELECT
http://www.mysql.com/doc/I/N/INSERT_SELECT.html
or REPLACE...SELECT
http://www.mysql.com/doc/R/E/REPLACE.html

The REPLACE is probably what you're looking for, but be careful, REPLACE
works exactly like INSERT, except that if an old record in the table has the
same value as a new record on a unique index, the old record is deleted
before the new record is inserted. 

HTH!

Jay

We are all apparently 'net' literate, why don't we use it to get the
information we need? After all, isn't that what a Google search is all
about?



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: UPDATE question, SQL syntax, etc.

2002-05-20 Thread Nick Stuart

There is no from clause in the update syntax. However, I'm not sure how
you would update a tablethe way you are trying to. I'm sure it can be done, and your 
SQL looks
correct besides the fromclause. Just take that out and see if what it says.

-Nick

 hi.  i'm new to the list and

have only been playing with mySQL for a
 few weeks now, i have a question regrading the

syntax of an UPDATE
 statement - i hope nobody minds me asking.

 i want to uopdate a

table with the data from another, i've written the
 following:

 update trackinfo

SET trackinfo.postcode = newtrackinfo.postcode FROM
 trackinfo, newtrackinfo
WHERE
trackinfo.telephone =
 newtrackinfo.telephone;

 it should update
trackinfo
with the postcodes from newtrackinfo, as
 long as the telephone numbers
match - but i get an
errror - it
 complains about the 'FROM...' onwards.

 am i missign
something
simple?

 cheers,

 .ben


 -
 Before posting, please
check:

http://www.mysql.com/manual.php   (the manual)

http://lists.mysql.com/   (the list
archive)

 To request this thread, e-mail mysql-
[EMAIL PROTECTED]
To
 unsubscribe, e-mail
 mysql-unsubscribe-
[EMAIL PROTECTED]
Trouble
 unsubscribing? Try:
http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: UPDATE question, SQL syntax, etc.

2002-05-20 Thread .ben

cheers for the responses.  i'll have to find another way, but thanks.

 .b

 -Original Message-
 From: Nick Stuart [mailto:[EMAIL PROTECTED]]
 Sent: 20 May 2002 13:46
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: UPDATE question, SQL syntax, etc.
 
 
 There is no from clause in the update syntax. However, I'm not sure how
 you would update a tablethe way you are trying to. I'm sure it 
 can be done, and your SQL looks
 correct besides the fromclause. Just take that out and see if 
 what it says.
 
 -Nick
 
  hi.  i'm new to the list and
 
 have only been playing with mySQL for a
  few weeks now, i have a question regrading the
 
 syntax of an UPDATE
  statement - i hope nobody minds me asking.
 
  i want to uopdate a
 
 table with the data from another, i've written the
  following:
 
  update trackinfo
 
 SET trackinfo.postcode = newtrackinfo.postcode FROM
  trackinfo, newtrackinfo
 WHERE
 trackinfo.telephone =
  newtrackinfo.telephone;
 
  it should update
 trackinfo
 with the postcodes from newtrackinfo, as
  long as the telephone numbers
 match - but i get an
 errror - it
  complains about the 'FROM...' onwards.
 
  am i missign
 something
 simple?
 
  cheers,
 
  .ben
 
 
  -
  Before posting, please
 check:
 
 http://www.mysql.com/manual.php   (the manual)
 
 http://lists.mysql.com/   (the list
 archive)
 
  To request this thread, e-mail mysql-
 [EMAIL PROTECTED]
 To
  unsubscribe, e-mail
  mysql-unsubscribe-
 [EMAIL PROTECTED]
 Trouble
  unsubscribing? Try:
 http://lists.mysql.com/php/unsubscribe.php
 
 
 
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail 
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php