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 |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-12-07 : 21:33:39
|
| I want to select a max(prop) id from table1 and update it in table2something like thisupdate tbl_prop_logset a.ref_id=max(b.ref_id)from tbl_prop_loga ,tbl_sale_detail bwhere a.prop_id in(select prop_id from tbl_sale_detail)and a.ref_id IS NULLThis gives an error..please help me with this query |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-12-07 : 22:11:12
|
| please somebody have a check on the query.... |
 |
|
|
AlDragon
Starting Member
12 Posts |
Posted - 2004-12-07 : 22:50:12
|
quote: Originally posted by sqllearner I want to select a max(prop) id from table1 and update it in table2something like thisupdate tbl_prop_logset a.ref_id=max(b.ref_id)from tbl_prop_loga ,tbl_sale_detail bwhere a.prop_id in(select prop_id from tbl_sale_detail)and a.ref_id IS NULLThis gives an error..please help me with this query
Try this outDeclare @ref_id int --not sure what type ref id isSET @ref_id = (Select max(ref_id) from tbl_sale_detail)update tbl_prop_logset ref_id = @ref_idfrom tbl_prop_loga where prop_id in (select prop_id from tbl_sale_detail) and ref_id IS NULLAl |
 |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-12-07 : 23:14:41
|
| Thanks a lot I was looking for something like this UPDATE Table1 SET field1=(SELECT MAX(field1) FROM table2 WHERE field2=table1.field2) |
 |
|
|
|
|
|