0

Having the following tables

tasks
  id
  title

tasks_cstm
  id
  task_id
  contact_number      

tasks_issues
  id
  task_id
  issue_id

issues
  id
  name

issues_cstm
  id
  id_issue
  frequency
  validity

I try to make an update query. This query requires to modify a field of a table based on a condition in which I must implement joins between three tables. I explain below.

I need to update the frequency field of the table issues_cstm to value '1500', this, where the field 'contact_number' of the table 'tasks_cstm' is equal to '456123'

I am trying this query but with no success

update
    issues_cstm
        inner join
    tasks_issues on issues_cstm.issue_id = tasks_issues.issue_id
        inner join
    tasks_cstm on tasks_cstm.task_id = tasks_issues.task_id
set
    issues_cstm.contact_number = '1500'
where
    tasks_cstm.contact_number = '456123';

I attach a sqlfiddle

I have no previous experience with update queries of this type. I appreciate your advice.

Mario
  • 4,784
  • 3
  • 34
  • 50
  • Your query looks pretty reasonable. What goes wrong when you try it? If you're trying to update the `frequency` field, though, you should do that. In the query above you're setting `contact_number` instead. See also https://stackoverflow.com/a/32082037/495319 – Wodin Nov 25 '18 at 21:53
  • changing `issues_cstm.contact_number` to `issues_cstm.frequency` like your text yeild [this](http://sqlfiddle.com/#!9/bd8bfb/1), which seems right. – danblack Nov 25 '18 at 21:59
  • Thanks you both for answering. Wodin thanks for the link this is what I was looking for. Danblack thanks for example. – Mario Nov 26 '18 at 02:42

0 Answers0