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 |
|
leite333
Starting Member
8 Posts |
Posted - 2011-08-02 : 01:28:27
|
| Hi i want some help with a complicate query. I have 3 tablesIn one table (51) with columns Code,Name,TelIn second table(16) CodeName (same with code from 51) and Description,CustomerIn third table(01) CodeCustomer,Customer,Names (same with Name from 51)Now whats is the wrong. The user put a new entry at table 51. And change an old one entry at 01 with the new one.For example gives at (51) 003,Test,23400So within the program that user use at table 01 the changes work andNames become from Test1(with code 001)->Testbut in the table 16 it keeps the old record at CodeName (001) and dont get the new one(003)So what i want to do is.. With the query get the last record from 51 and more right get only the last Code(same with CodeName). Look at table 01 in wich Customers is the new code and then replace at table 16 the old one code with new one.I hope i didnt confuse you....We can solve it step by step..like first how i will get the last code from table 51 and second how i can search at table 01 where exist??? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-02 : 02:24:57
|
| sorry not clear from your explanation. can you explain with a data sample to clarify what you're trying to achieve?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
leite333
Starting Member
8 Posts |
Posted - 2011-08-03 : 01:27:39
|
| Ok Here an example.....Table 01:(Customers)CustomerId Company NameSeller 001 George Test Soros 002 Albert Red Soros 003 Nick Blue White Table 51:(Sellers)CodeSeller NameSeller Tel00001 Soros Nick 123456700002 White Maria 2345678Table 16:(Receipts)CodeCustomer CustomerDescription CodeRe DeReceipt SellerId 001 George Test 123 TDA 00001 002 Albert Red 124 TDA 00001 003 Nick Blue 125 TDA 00002 001 George Test 030 APD 00001Now the same columns are: CodeCustomer=01.Customer CustomerDescription=01.Company SellerId=51.CodeSellerQuestion:The user make a new record at table 51 -> 00003 Melina Zack 4875847Then the user change the at table 01 the seller at customer 003 Nick Blue with new one seller (00003) Melina ZackAt table 01 everything is ok. But at table 16 at third row the old code of seller 00002 remains and i want to change with new one 00003So as i thinking it i think the last row of 51 that user insert have to keep it at memory compare at 01 in what customers exist and then make the changes with the new code seller at 016I dont know if this can work with update...Do i need any function to search and compare at table 01????Help please...Any other ideas? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-03 : 01:31:18
|
| what all will be available as input from user? does user pass the customerid of customer whose seller is to be updated from 51?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
leite333
Starting Member
8 Posts |
Posted - 2011-08-03 : 02:47:20
|
| user can input sellers at table 51 with new codesand also user can change the seller at table 1its software program that database is behind.... |
 |
|
|
|
|
|