Answer the question
In order to leave comments, you need to log in
How to correctly implement validation when binding two text-boxes?
In C# (Windows Form)
I made the binding of the text field of the 1st User-Control to another as follows. They now completely reproduce each other.
this.controlFIO.FIO_T_FA.DataBindings.Add( "Text", this.controlFIO_M.FIO_T_FA, "Text", true, DataSourceUpdateMode.OnValidation );
Answer the question
In order to leave comments, you need to log in
You make a selection of all tables, and you already build the code as you like
This can only be solved in a procedural programming context when post-processing query results, for example, in PHP.
/*Функция преобразования выборки в матрицу */
function get_matrix($rows)
{
// получаем все значения по id - измерению матрицы (строки матрицы)
// можно сделать запросом select distinct id from table order by id
foreach($rows as $row)
$id_dem[$row['id']] = 1;
// получаем все значения по date - измерению матрицы (столбцы матрицы)
// можно сделать запросом select distinct date from table order by date
foreach($rows as $row)
$date_dem[$row['date']] = 1;
$map = null; // если нет значений размерности матрицы, то функция вернет null
// получаем карту не-null значений - непустые ячейки матрицы
foreach($rows as $row)
$map[$row['id']][$row['date']] = $row['count'];
// дополняем карту null значениями - получаем полноценную матрицу
if(isset($id_dem) && isset($date_dem))
foreach($id_dem as $id => $val_id)
foreach($date_dem as $date => $val_date)
$map[$id][$date] = array_key_exists($id, $map) && array_key_exists($date, $map[$id])
? $map[$id][$date] : null;
return $map;
}
It's clear. So it's just post-processing. I hoped that there are mechanisms for implementing this in SQL.
And if there is one more record with id=1 in the selection?
You cannot change the number of columns in a query.
You can do it differently, the first column is id, the second is an array of count and the third is the date. This can be achieved using the array_agg
function
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question