Member Avatar for mehnihma

Hi

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:
`Telefonist='".$_SESSION["UserName"]."

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

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

Code:

$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"]."'";

CustomQuery($sql_zapis_do30);

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

Thanks

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.

Member Avatar for mehnihma

Is there maybe a better way to do this?

Be a part of the DaniWeb community

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