how to sum multiple columns into one result from database in php? is that posible?

Sandi Budic

i have big database table and i need result from multiple columns into one. its about how much people is checked from some conturies and every contry has own column. here is some of it: rs_turista, rs_nocenja, agencija_turista, agencija_nocenja, at_turista, at_nocenja, be_turista, be_nocenja, ba_turista... they is checking every day. i need to sum it all in php for report. is that posible?

Jakub Kania

Don't do it in PHP, that's needlessly selecting too much data from a database. All you gotta do is use a SUM() and + like so:

SELECT SUM(column1) + SUM(column2) + SUM(column3) + ... AS total
FROM table
WHERE <filters for a date or other requirements>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get all the result columns from database with other custom(concat, sum, count) columns in Jooq

How to get Mysql SUM of multiple columns in database

How to select multiple columns, sum one column and group by multiple columns

Codeigniter: Display multiple columns from database as one

Flask multiple parameters how to avoid multiple if statements when querying multiple columns of a database from one url

How to search multiple columns in database with one searchbar

PHP SQL : How to save data to multiple database from one html form OR how to copy data from one database to another database automatically

MySql: select values from one column into multiple columns in the result

How to sum one column from multiple

How to display a php result from database in HTML table on the same webpage (in one script)

How can I group multiple columns and sum the last one?

How to Create a Multiple Choice Android List View with result gotten from Mysql database using PHP?

How to calculate the sum of number array elements from multiple database rows using php?

How to subtract multiple columns from one another

Java or Scala to retrive multiple columns from database as one line

How to display sum of columns from sql database into Java application?

how to get multiple data from two different table from one database in php

Formatting results across multiple columns from MySQL database with PHP

how to sum up values of specific columns from multiple file

How to get total of multiple columns from sum of quantity and average of price?

how to receive just one result from a query in a mysql database?

Querying multiple columns in a database and finding their sum

How to insert data to multiple column database from indexed array text input name PHP using one foreach?

MYSQL - Sum from multiple columns in one table divided by one row in a JOINED other table

How to merge multiple values from multiple columns into one row?

Compare columns from multiple tables in one query PHP/SQL

How can fetch multiple result based on the key from the MongoDB database?

MySQL result select SUM from the database

Sum and grouping multiple columns into one value in linq