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

apache - setting document root in antoher partition on ubuntu -

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

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -