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 > set Column value with select statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-13-03, 12:15
bobwilli bobwilli is offline
Registered User
 
Join Date: Nov 2003
Posts: 7
set Column value with select statement

Is there a way to set the value for a particula column data using only SELECT statement?

ex.
update TABLE set COLUMN = value where COULMNX = value ;

instead of this, I need to use only a SELECT statement to do the same function.
Reply With Quote
  #2 (permalink)  
Old 11-13-03, 15:03
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Re: set Column value with select statement

Use REPLACE, the trick is that you must have a primary key or a unique index on the table. This command will replace rows with the same unique index or insert the row like normal. You can use it just like an INSERT.

Quote:
Originally posted by bobwilli
Is there a way to set the value for a particula column data using only SELECT statement?

ex.
update TABLE set COLUMN = value where COULMNX = value ;

instead of this, I need to use only a SELECT statement to do the same function.
Reply With Quote
  #3 (permalink)  
Old 11-17-03, 09:38
khibinite khibinite is offline
Registered User
 
Join Date: Oct 2003
Posts: 63
Re: set Column value with select statement

Quote:
Originally posted by aus
Use REPLACE, the trick is that you must have a primary key or a unique index on the table. This command will replace rows with the same unique index or insert the row like normal. You can use it just like an INSERT.
Oh, that's great, I didn't kow about this function .
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