| | |
UPDATE with INNER JOIN
Please support our MS SQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 1
Reputation:
Solved Threads: 0
I have the next query, but it doesn't update when I have but of a product with the same code in the table detallefacturas
UPDATE dbo.Kardex SET dbo.Kardex.SaldoDocumental = dbo.Kardex.SaldoDocumental + dbo.DetalleFacturas.Cantidad
FROM dbo.Kardex INNER JOIN dbo.DetalleFacturas ON
(dbo.Kardex.CodigoZofriID = dbo.DetalleFacturas.CodigoZofriID) WHERE dbo.DetalleFacturas.FacturaID = @FacturaID
for example.
DetalleFacturas
Item CodigoZofriID Cantidad
1 001-08-000124-001 10
2 001-08-000124-001 20
3 001-08-000222-001 5
Kardex
CodigoZofriID IngresoDocumental SaldoDocumental
001-08-000124-001 400 370
001-08-000222-001 100 95
once made the query this is what see
Kardex
CodigoZofriID IngresoDocumental SaldoDocumental
001-08-000124-001 400 380 BAD
001-08-000222-001 100 100 OK
thanks. Rodrigo.
UPDATE dbo.Kardex SET dbo.Kardex.SaldoDocumental = dbo.Kardex.SaldoDocumental + dbo.DetalleFacturas.Cantidad
FROM dbo.Kardex INNER JOIN dbo.DetalleFacturas ON
(dbo.Kardex.CodigoZofriID = dbo.DetalleFacturas.CodigoZofriID) WHERE dbo.DetalleFacturas.FacturaID = @FacturaID
for example.
DetalleFacturas
Item CodigoZofriID Cantidad
1 001-08-000124-001 10
2 001-08-000124-001 20
3 001-08-000222-001 5
Kardex
CodigoZofriID IngresoDocumental SaldoDocumental
001-08-000124-001 400 370
001-08-000222-001 100 95
once made the query this is what see
Kardex
CodigoZofriID IngresoDocumental SaldoDocumental
001-08-000124-001 400 380 BAD
001-08-000222-001 100 100 OK
thanks. Rodrigo.
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
1
#2 15 Days Ago
Have you tried:
MS SQL Syntax (Toggle Plain Text)
UPDATE dbo.Kardex SET dbo.Kardex.SaldoDocumental = dbo.Kardex.SaldoDocumental + dbo.DetalleFacturas.Cantidad FROM dbo.DetalleFacturas WHERE dbo.DetalleFacturas.FacturaID = @FacturaID AND dbo.Kardex.CodigoZofriID = dbo.DetalleFacturas.CodigoZofriID
![]() |
Similar Threads
- :::UNLIMITED PR7,8,9 Backlinks FREE::: (Ad Space for Sale)
- T-SQL UPDATE Statement (Legacy and Other Languages)
- Update and insert query in one (MySQL)
- Update query in event procedure for Form (Visual Basic 4 / 5 / 6)
- update two rows in one query (MS SQL)
- Computed column in view VS trigger on update (MS SQL)
- IE 6 Can't open new windows from link clicked (Web Browsers)
- Free ad impressions for your site (IT Professionals' Lounge)
- My hijakit Log (Viruses, Spyware and other Nasties)
Other Threads in the MS SQL Forum
- Previous Thread: MS SQL
- Next Thread: Getting sum of cost from one table where quantity on another table
| Thread Tools | Search this Thread |





