Perhaps something like this:
SELECT e.employee_id, e.first_name, e.last_name,
CONCAT(addr.address_one,',',addr.address_two,',',state) fulladdr,
CONCAT(ph.mobile',',ph.mobile_one,',',ph.phone) phonenumbers,
e.dob, e.maritial_id, e.sex_id, e.photo, s.sex_label
FROM employee e
INNER JOIN sex s ON e.sex_id = s.id
INNER JOIN address addr ON e.address_id = addr.id
INNER JOIN phone ph ON e.phone_id = ph.id;
If you are interested in returning all the values as columns, you need to be try something very adventurous. First look at your query
SELECT
CONCAT(id, '-', date),
MAX(IF(`num` = 0, avg, NULL)) num0
FROM table
GROUP BY
id,
date;
If would be a big mess to get MySQL to execute it as a query by giving MySQL the query with each column formulated.
Perhaps you can get MySQL to concatenate the column values using GROUP_CONCAT. That function was designed for aggregation (or aggravation if you are the actual developer). You can take all the num values can display it as a column-separated listed of numbers like this:
SELECT
CONCAT(id, '-', date),
GROUP_CONCAT(IF(`num` = 0, avg, 0))) numlist
FROM table
GROUP BY
id,
date;
You can also change the list to be delimited by pipes instead of commas like this:
SELECT
CONCAT(id, '-', date),
GROUP_CONCAT(IF(`num` = 0, avg, 0)) SEPARATOR '|') numlist
FROM table
GROUP BY
id,
date;
The default maximum length of a GROUP_CONCAT is 1024.
You need to change that max length in the session using this:
SET group_concat_max_len = 10240;
before you issue your query.
Give it a Try !!!
Best Answer
Unlike the last question, there is no
AVERAGE()
function other thanGROUP BY
aggregation.This one can only be done by Dynamic SQL
Here are the Steps
bangla_1st+bangla_2nd+english_1st+english_2nd+...+science
Here is the Dynamic SQL for it
GIVE IT A TRY !!!