Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update table from a query result

Status
Not open for further replies.

thedaver

IS-IT--Management
Jul 12, 2001
2,741
US
I want to use the mysql command line to do this

select rec_id from records where condition=true; update records set thisfield="beer" where rec_id in (the previous list of selected records);

Some clever person must have figured this out. I'm on 3.23.4x,... not v4 MySQL. THANKS!

"Surfinbox Shares" - A fundraising program that builds revenue from dialup Internet users.
 
Try :

update records
set thisfield="beer"
where rec_id in
(select rec_id
from records
where condition=true);


This query must be ok
 
bchaigne:
He's already said he's running 3.x and as such subqueries aren't supported.


thedaver:
What's your condition?

Can't you just take the condition from the SELECT query and move it to the UPDATE query? Something like:

UPDATE records SET thisfield="beer" WHERE condition



Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top