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 > query help, I thought this would be simple but I cant get it.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-19-04, 15:01
doctorbombay doctorbombay is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 08-20-04, 01:01
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
You probably need the Cast() function.

-PatP
Reply With Quote
  #3 (permalink)  
Old 08-20-04, 09:33
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
update yourtable
   set attach_file = topic_id 
 where author_name='john'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 08-20-04, 09:34
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Does MySQL do an implict cast between numeric and string?!?!

-PatP
Reply With Quote
  #5 (permalink)  
Old 08-20-04, 09:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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