1

I am working on a simple DB and while I am a NOOB I have an update string where table 'employee' updates properly, table 'job' changes all values to the same except primary key.

UPDATE employee,job 
SET employee.name='name', employee.vorname='vorname',
employee.strasse='strasse' , employee.haus_nr='haus_nr',
employee.platz='platz', employee.stadt='stadt', 
employee.telefon='telefon', employee.emp_nr='emp_nr', 
job.emp_nr='emp_nr', job.job='job', job.lohn='lohn' 
WHERE employee.emp_nr=emp_nr AND job.emp_nr=emp_nr

So in end effect all of the entries in 'job' will have the same emp_nr, the same job and the same lohn.

skyboyer
  • 22,209
  • 7
  • 57
  • 64
  • 1
    Whats your question? And also, you should try to format your code blocks properly, see https://stackoverflow.com/help/formatting – simon.ro Jan 21 '18 at 18:56
  • Also please checkout [when-should-i-use-prepared-statements](https://stackoverflow.com/questions/24988867/when-should-i-use-prepared-statements) – Cemal Jan 21 '18 at 19:52
  • have you tried to execute that query directly through any client(say, phpMyAdmin)? – skyboyer Jan 22 '18 at 07:33
  • what's the status of *this* post? someone gave you an answer, but failed to comment if it worked or not and if it did work, then the question should be marked as solved by accepting the answer. – Funk Forty Niner Jan 31 '18 at 12:51

1 Answers1

0

Try using:

    ... WHERE employee.emp_nr=$emp_nr AND job.emp_nr=employee.emp_nr";

This should result in a Join of employee and job on emp_r, the update will work on the join then which will provide the expected result.

mottek
  • 929
  • 5
  • 12
  • since `emp_nr` value is the same(whatever it is) it must work the same way: making Cartesian multiplication and filtering next step – skyboyer Jan 21 '18 at 18:59