Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    1

    Unanswered: query help, I thought this would be simple but I cant get it.

    Well, Im no guru but I thought I could do this but cant, help please.

    For a selection of records in a table, ie; where author_name='john'

    I want to take the numeric data in a certain field ie; field is named topic_id

    and copy that data into another field in the same record ie; field is named attach_file

    thanks in advance

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    You probably need the Cast() function.

    -PatP

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    update yourtable
       set attach_file = topic_id 
     where author_name='john'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Does MySQL do an implict cast between numeric and string?!?!

    -PatP

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    mysql will do an implicit cast to anything depending on context

    (one of the reasons it is so cuddly)

    in this particular case, there is no evidence that the other field is a string

    attach_file could be numeric, no?

    but to answer your question, yes, it's implicit
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •