Questions tagged as 'mysql'

1
answer

How to return multiple fields as a single array or string?

I have a table in the database with several phones, the name of the fields is numbered as follows: telefone1, telefone2, telefone3 your return is like this: Array ( [telefone1] => 190 [telefone2] => 197 [telefone3] =&g...
asked by 30.06.2018 / 02:51
1
answer

How to make an INNER JOIN in a single table with 3 keys?

I have a table that has the following structure: origem|papel|campo018|campo040|mercado|Master_key| The Master_key column can have two values: 'NY' OR 'MS' , I'd like to compare the rows in which Master_key is equal to...
asked by 19.06.2018 / 20:49
1
answer

Bring column values and sum total with php + mysql

I have the following script that brings the values I need, how do I also bring the total sum of $ row ['value']? $results = $mysqli->query("SELECT * FROM cv_contratos_dependentes WHERE idcontrato = $idcontrato"); //get all records from add_...
asked by 11.12.2017 / 17:03
3
answers

Use BETWEEN together with IN ()

I would like to compare several dates within a date range. I tried to perform the query below but I can not get a proper logic. Query with Array + BETWEEN in Mysql, or rather use the expression IN() along with BETWEEN . I ha...
asked by 22.03.2018 / 18:09
1
answer

Mysql - perform an update via db with "set price = price - 5%" [duplicate]

How do I do an update where the price of the product will decrease by percentage?    Example:       Table:       id | products       10 | 1.40 How do I make an update that returns the value 1.40 - 5%?     
asked by 24.10.2018 / 15:15
2
answers

Balance by date in mysql

I have a table requests and would like to return the following situation. select all the requests of an idCliente of the current month adding the values of the same ones. type select * from pedidos where idCliente = id and dataPedido (the...
asked by 24.10.2018 / 04:30
1
answer

Help button back php

Good afternoon,  Button to return php.  I use the function below to go to the next question from a question system that I have, I could not create this function to go back, would anyone have any tips? Button: echo"<button id='button' t...
asked by 14.04.2016 / 21:00
4
answers

How do I do a SELECT then an INSERT [closed]

How do I do a SELECT and if it returns more than 1 record does the UPDATE and if it returns 0 records does the INSERT? Look how I've done here but it's not working: if(isset($_POST['submit'])){ $query = $conexao->prepare("SELECT id_m...
asked by 15.12.2015 / 21:19
2
answers

Infinite listing with mysqli_fetch_array ()

My code returns the database query, but lists only the last item entered, and lists it infinitely. I wonder where I'm going wrong. <?php //Início da listagem $servidor = 'localhost'; $usuario = 'root'; $senha = ''; $banco = 'portfolio';...
asked by 13.09.2017 / 21:53
2
answers

PHP - Create a checkbox list dynamically

I have the following code, where I select categories from a MYSQL table. <?php include 'conect.php'; // array que conterá as categorias $cats = array(); $sql = "SELECT id_carac, nome_carac FROM carac"; $exec = $con->query( $sql ) or e...
asked by 06.07.2016 / 04:31