Questions tagged as 'mysql'

2
answers

Checking empty column with CASE in MySQL

I'm having a hard time performing a query on a customer table. I need to fetch two columns ( nomeCli and nomeFantasiaCli ) and transform them into one: Nome . In short, when the client name is not populated in the client ta...
asked by 31.01.2014 / 13:01
3
answers

Using preg_replace invalid password with SHA1

I was using preg_replace , to avoid SQL injection: $senha = preg_replace('/[^[:alpha:]_]/', '',$_POST['senha']); When comparing the $senha received by POST with the bank password (using SHA1), they are not compatible. Does a...
asked by 16.12.2015 / 16:46
2
answers

How to compare two arrays and return the difference between them?

I have 2 arrays that come from 2 different banks, one comes from the sql server another from mysql. Mysl query returns like this .. array (size=6) 0 => string 'ultimoteste3' (length=12) 1 => string 'ultimoteste3' (length=12)...
asked by 26.01.2016 / 12:43
2
answers

Sort by the number of repetitions of a column?

In a query in MySql I need to select the results and sort the results based on how much they are repeated using the id_livro column, for example: My comments table: +----------------+-------------+ | id_livro | comentario | +-...
asked by 02.02.2017 / 18:35
1
answer

How to change a comma, by a point, into a decimal number inside a string

I was trying to do the following: String: ajskjnsjs, eeiisois, 10,98 oismsnsjh; In this case, you just wanted to change the comma of the number by a period , leaving the rest of the string equal. I was using the regexp_...
asked by 05.04.2017 / 00:32
3
answers

How to do dynamic and generic preparation with mysqli?

I have a mobile application that sends me the following parameters $tabela = $_POST[“tabela”]; // ex: “pessoa” $atributos = $_POST[“atributos”]; // ex: “codigo, nome, cpf” $valores = $_POST[“valores”]; // ex: “10, Rafael, 1234567890”...
asked by 20.01.2017 / 11:21
1
answer

Remove characters from a field in MySQL

I have a table where I have several codes, I would like to get all the codes that start with the following sequence 1170 and remove it. For example, the following code 11701287871 would be 1287871 . Is this possible?     
asked by 15.12.2016 / 20:51
3
answers

Optimization of PHP functions for querys to the database

I often see different functions in PHP for each query . I would like to know if there is any way to do the following in an PDO connection: function get_user_data($table, $columm, $required) { $db = conn(); $data = array(':value' => $r...
asked by 06.03.2015 / 11:03
2
answers

Normalization of MySQL tables

I am creating a system for employee registration, but I would like to start in a standardized way; I thought something like that tb_funcionario (id_func, id_funcao, id_depto, nome_func, data_nasc, end_fun, dt_admissao, dt_demissao) tb_funcao...
asked by 25.02.2015 / 03:58
1
answer

Error with default value for datetime field in MySQL

I had a problem trying to run my database script on the server. The error already gives in the first table that the script generates: CREATE TABLE IF NOT EXISTS 'categoria' ( 'cd_categoria' int(255) NOT NULL, 'titulo' varchar(100) NOT NULL,...
asked by 23.06.2016 / 17:09