I´m doing a query
SELECT ROUND((SUM(refracciones.total)+(serviciosrealizados.total)),2)
FROM refracciones, serviciosrealizados
WHERE refracciones.id_ticket = '$idticket' AND serviciosrealizados.id_ticket = '$idticket'
2 tables:
- refracciones
- serviciosrealizados
2 columns:
- refracciones.total
- serviciosrealizados.total
At the moment the query is working but just if I insert data in both table.
I will like the query show me the total of refracciones.total + serviciosrealizados.total if one of the field are empty show me the total with refracciones.total or serviciosrealizados.total
mysqliand PDO where any user-supplied data is specified with a?or:nameindicator that’s later populated usingbind_paramorexecutedepending on which one you’re using.