Create Virtual Column in mysql -


i have mysql query this:

$statement=$pdo->prepare("select id activity_id,type,status,description, (select sum(price*worked_hours) tbl_working_hours  id_act = activity_id) total_hours tbl_activity"); 

there 2 tables:

1- tbl_activity

2- tbl_working_hours

i trying create virtual column each row based on summary table.

thanks

you might want use subqueries

select [...], (select count(*) mytable) count myothertable 

thats solution comming mind. problem way pretty costly when comes performance.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -