Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-12-14 : 13:25:57
|
I have a querySELECT tabled. * , tablep. * FROM tabled, tablepWHERE tabled.id=5 =tablep.id=5how can cahnge this to be an update query -- meaning updating the results of teh above joined query? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-12-14 : 13:32:02
|
Which table do you want to update and what exactly do you want to update and with what values?Here's how to update the tabled table:UPDATE dSET SomeColumn = ...FROM tabled dINNER JOIN tablep ON d.id = p.idWHERE d.id = 5Also the SELECT statement that you posted is invalid T-SQL syntax.Tara Kizer |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-12-14 : 13:53:58
|
can you help me with what's wrong with the below (in mysql) the select without the update worksUPDATE orders SET amount_paid = amount WHERE orders_id IN (SELECT orders.orders_idFROM customer, ordersWHERE (customer.contacts_id_primary = orders.contacts_id_primary)AND (customer.event = '1'AND orders.event =1)AND (customer.amount = orders.amount)) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-12-14 : 14:29:57
|
You need to look at the example that I provided in my last post and use that as a template for when you need to join two tables together in an UPDATE statement. Your posted query doesn't attempt to use it.UPDATE oSET amount_paid = c.amountFROM orders oINNER JOIN customer cON o.contacts_id_primary = c.contacts_id_primary AND c.amount = o.amountWHERE c.event = '1' AND o.event = '1'Tara Kizer |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-14 : 23:40:52
|
1 This is SQL Server Forum2 I dont think Update with inner join is supported at MySQL3 This is your third question on Mysql4 You should post at www.DBForums.com or www.MYSQL.com as I suggested in other topicsMadhivananFailing to plan is Planning to fail |
|
|
|
|
|