Questions tagged as 'mysql'

1
answer

Get single lines in the database, mysql

It is necessary to get rows that do not have duplicates in a table, I did searches and found the DISTINCT function, but this does not solve the problem, because it somehow groups the data. One way to solve this would be to use PHP and...
asked by 22.09.2017 / 17:11
2
answers

LEFT JOIN with GROUP BY

I'm using PHP and MySQL, I have two tables in the database: POSTAGEM id ---- 1 3 13 CURTIDA id | id_usuario | id_postagem ----------------------------- 1 | 1 | 1 7 | 12 | 1 What I can not do is the following:...
asked by 27.09.2017 / 19:16
1
answer

Is my database access role secure?

I have a file that has CRUD operations with PDO and MySQL, my question is if I leave my functions as the function below: function delete($tabela, $id) { global $con; $sql = "DELETE FROM " . $tabela . " WHERE id=:id"; if(is_arra...
asked by 25.09.2017 / 00:36
1
answer

Doubt with SQL / PHP

I have the following query: $qrysel = "select * from pack"; $ressel = mysqli_query($db, $qrysel); $obj = mysqli_fetch_object($ressel); In html I have this: <?= $obj['pack_name']; ?> How could I make it show the value according to...
asked by 25.09.2017 / 20:10
1
answer

Stored Procedure with if

I have a table with the name, id, and salary fields. I need a procedure that changes the employee's salary, if it receives one, it should raise the salary by 300 reais, in case another amount decreases the salary by 500 reais. Do you know...
asked by 29.09.2017 / 01:01
1
answer

Query mysql to get data from two rows and join in just one

Hello, I can not execute a query in mysql. I have a table that has the following fields: numero | data | descricao | norma 001 | 2017-02-28 | Lapis | NBR 001 | 2017-02-28 | Lapis | ISO As in the example above, there are...
asked by 30.09.2017 / 19:54
1
answer

Return an in_array () true within an SQL result

I have a function inside the class UsuarioVisitas : // Retorna o array com os mais visitados public function CS_GetMaisVisitados($sql_aux) { global $objConexao; $strSql = "SELECT cod_usuario, SUM(count_view) AS total_visitas...
asked by 26.05.2017 / 17:47
2
answers

Update with character in middle of string

I have thousands of records with code in a very peculiar format that identifies boxes on street poles. Eg: 21.305-005 / 100-A However, this code is currently in the format 21305005100-A. As the position of the punctuation is fixed, standar...
asked by 30.05.2017 / 20:38
1
answer

How to leave the date in this format 27-Feb-17 at 21:52

fast thing I need to know how to leave the date in this format 27-Feb-17 at 21:52 my code is this <?php echo date('d/m/Y H:i', $news['published']); ?>     
asked by 14.05.2017 / 20:00
1
answer

Pick up all product category levels

I have a question. I have a table of categories: CREATE TABLE 'categorias' ( 'id' int(10) UNSIGNED NOT NULL, 'parent_id' int(10) DEFAULT NULL, 'lft' int(10) DEFAULT NULL, 'rght' int(10) DEFAULT NULL, 'nome' varchar(255) DEFAULT NULL,...
asked by 10.05.2017 / 20:35