This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Updating two tables with an inner join

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble updating it. I have two tables one is employees and other is attendance.

employees table has fields as (id, employee_id, firstname, lastname, address, email, salary, creacted_on) and attendance table has fields as (id, employee_id, date, time, description). Here is my code for editing.



page edit :

 
Marshal
Posts: 7933
548
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

You may want to explain the problem a bit more. You mentioned you have a trouble updating the table for what it seems, however, that was it. It may be hard for somebody to help you - there could be many troubles.
 
Saloon Keeper
Posts: 23006
156
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know of any dialect of SQL that allows one SQL command to update more than one table at a time.

You can use a SELECT with a JOIN to figure out which rows to update, but each table must be updated separately.

Obviously that, however, poses a risk - what would happen if another user tried to access that data after the first table had been updated but before the second table was updated?

The solution to that is to wrap the updates in a transaction. Begin the transaction, do each table update, then commit the transaction. You may need to turn auto-commit off on your database to make that work. Also, if there is a problem while doing updating, you'd rollback the transaction rather than committing it.

Transactions make the updates an atomic operation, so there is no risk of someone getting in there while things are only half-done. It's all or nothing.
 
Abdallah Taha
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Guys, What I'm looking for is to update data from table attendance which is LEFT INNER with table employees. So I used this query but I'm still confused why it doesn't work the update.
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic