I am new to MySQL and not too shure how can I update row form another table while cheking if logged in user is same:

And also I need to check if date is the same so It gets to right pearson on right date in a row:

here I am trying to count all 1ones and enter sum to from table1 to table2 in specific place.


$sql_zapis_do30 = "UPDATE telefonisti_podaci
SET `Total tura do 30` = (Select COUNT(*) `Ture do 30` from log,telefonisti_podaci WHERE `Ture do 30` is not null AND `Ture do 30`=1 AND log.Datum=telefonisti_podaci.Datum )
WHERE `Telefonist`='".$_SESSION["UserName"]."'";


I get error:
You can't specify target table 'telefonisti_podaci' for update in FROM clause


You can't specify target table 'telefonisti_podaci' for update in FROM claus

This looks like a non-default MySQL error. Maybe it's a custom error triggered by your CustomQuery function? If so, then you could check that function to see when and thus why it is thrown/given.

Is there maybe a better way to do this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.