Posts by Marcus Italo • 570 points
26 posts
-
0
votes1
answer79
viewsA: Return of several CASE in a single line
SELECT max(result.bin_cartao), max(result.rede), max(result.bandeira), max(result.nsu_sitef), max(result.nsu_host), max(result.nsu_credito), max(result.autorizacao), max(result.aprovacao),…
-
1
votes3
answers127
viewsA: How to get dates with X days interval?
You could use the following SELECT: SELECT * FROM table WHERE MOD(DATEDIFF(CURDATE(), data), 7) = 0 Let’s go to the explanation: The function DATEDIFF() returns the interval in days between the…
-
3
votes2
answers65
viewsA: Function that prints indexes of an array incrementally
<?php $numeros = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]; $indice = 0; $incremento = 0; do{ echo…
-
0
votes1
answer26
viewsA: Help, how do I save the image path in my bank?
You could do it this way; CREATE TABLE produtos ( id int NOT NULL auto_increment primary key, nome varchar(255) NOT NULL, preco decimal(10,2) NOT NULL, url_imagem TEXT ) ENGINE=InnoDB; INSERT INTO…
sqlanswered Marcus Italo 570 -
2
votes2
answers117
viewsA: Why do you enter if even if it is false?
You can do the same thing by saving some variables and assignments. Behold: class Exer8 { public static void main(String[] args) { int indMaior = 0; int indMenor = 0; double[] notas = {8, 5, 7, 2,…
-
2
votes1
answer172
viewsA: Summarize fields with direct calculations in sql query
Sql: SELECT CLIENTES.ID_CLIENTE, CLIENTES.CLIENTE, SUM(DAV_ITENS.QUANTIDADE) AS QUANTIDADES, SUM(DAV_ITENS.VALOR_CUSTO * DAV_ITENS.QUANTIDADE) AS VALOR_CUSTO, SUM(DAV_ITENS.VALOR_TOTAL) AS…
-
0
votes1
answer516
viewsA: Error with Session in PHP
You are trying to access a Session attribute that only $_SESSION['status_register'] will only be created if you enter an if($connected->query($sql) === TRUE): Filing cabinet register.php with the…
-
0
votes1
answer154
viewsA: Return Json Mysql array
If you only have one photo per category, you could make a single select: $sql = "SELECT * FROM tbl_categorias_fotos cat LEFT JOIN tbl_fotos_empresa fotos ON cat.id_cat_fotos = fotos.id_cat_fotos"; I…
-
1
votes8
answers64831
viewsA: How to check if a checkbox is checked with PHP?
If in your form, you have for example: <input type="checkbox" name="status" value="ativo"> When submitting the form, if the field is NOT marked, it will not be sent to your server. Soon it…
phpanswered Marcus Italo 570 -
4
votes2
answers460
viewsA: Generate CSV with side-by-side results in PHP
$codigo_cliente = 0; $pula_linha="\n"; while: if ($ano_atual2==0) { $ano_atual2 = $ano; } if ( $ano != $ano_atual2 ) : $ano_atual2 = $ano; $dadosTXT2 = "$pula_linha$nome_repre;$mes;$ano$pula_linha";…
-
-1
votes3
answers268
viewsA: Select postgres between two values
I’m taking into consideration that you will pass the value of Percentage of customer return for this select, or if you need to, you can do oj Necessary Joins. SELECT id,taxa_proposta,taxa_desconto…
-
0
votes5
answers7645
viewsA: Javascript number stack pairs
I hope it helps; <script type="text/javascript"> var j=0, pares="", impares=""; while (j<=10){ //Concatena os números pares pares += (j%2 == 0 )?j+",":""; //Concatena os números impares…
javascriptanswered Marcus Italo 570 -
0
votes2
answers2222
viewsA: Postgresql currency conversion
Well. It’s not pretty! But I could do this: SELECT REPLACE(REPLACE(REPLACE(REPLACE('$14,825.00'::text,'$','R$ '),',','|'),'.',','),'|','.') In your example I believe you should stay like this:…
postgresqlanswered Marcus Italo 570 -
0
votes3
answers2314
viewsA: How to calculate two columns and compare the result with another column?
SELECT ( SUM(CASE WHEN natureza_operacao = '1' THEN qtde_pontos ELSE 0 END) - SUM(CASE WHEN natureza_operacao = '2' THEN qtde_pontos ELSE 0 END) ) as resultado from dbo.tbl_cc_ponto where re =…
-
0
votes3
answers789
viewsA: Problem sorting sql with orderby Date in postgresql
Try So select sum(total) as total, datavencimento from ( select sum (con_valoraserpago) as total, to_char(con_datavencimento,'mm/yyyy') as datavencimento from conta where con_formapagamento='V'…
-
1
votes1
answer43
viewsA: MYSQL - Query summing 8 identical tables
I don’t know if it’s the most beautiful option but I believe that if you use one UNION ALL in the tables for example; SELECT juncao.ID, juncao.TIPO, SUM(juncao.valor1) total1, SUM(juncao.valor2)…
-
3
votes2
answers166
viewsA: Count IF Mysql Workbench
A Solution that solves but less elegant would be to do a subquery: SELECT t.ID,sub.contador FROM tabela as t INNER JOIN (select ID, Count(ID) contador from tabela group by ID) as sub ON sub.ID =…
-
4
votes1
answer759
viewsA: Sql Query, fetch data from given ID
From what I understand you would like to pick up records at a range, you could be using for example the OFFSET and LIMIT SELECT coluna FROM tabela ORDER BY id LIMIT 10 OFFSET 10; In this case, you…
-
1
votes1
answer917
viewsA: Search by string in SQL/ PHP database
The solution found was the use of a LIKE, in the search : $consulta = "SELECT * FROM app_usuarios WHERE cat LIKE '$categ'
-
0
votes2
answers328
viewsA: What would the query look like to return values in a given range?
SELECT * FROM tblVacinas WHERE dt_vencimento >= DATE_SUB(curdate(), INTERVAL 10 DAY); Try using the DATE_SUB Command(); Reference :…
-
3
votes3
answers18167
viewsA: PDO Drivers for SQL Server
You will need some . dll files that you can find in the following link: https://www.microsoft.com/en-us/download/details.aspx?id=20098 Since your PHP is 5.5, Download the SQLSRV31 File. After…
-
2
votes3
answers2517
viewsA: How to connect PHP 5.6 to Sql Server 2008?
You will need some . dll files that you can find in the following link: https://www.microsoft.com/en-us/download/details.aspx?id=20098 Since your PHP is 5.6, Download SQLSRV32 File. After…
-
0
votes1
answer608
viewsA: PHP PDO for SQL SERVER
You will need some . dll files that you can find in the following link: https://www.microsoft.com/en-us/download/details.aspx?id=20098 Since your PHP is 5.6, Download SQLSRV32 File. After…
-
4
votes1
answer1324
viewsA: PHP take value from a multidimensional array
When you use the json_decode function, it converts the json data into an associative array, so you can use the foreach calling element of an array using an index and not attributes of an object. For…
-
1
votes1
answer107
viewsA: Relate MYSQL Table
A good suggestion would be you create another table, where you could store the relationship between these people, For example: CREATE TABLE Parentesco( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,…
databaseanswered Marcus Italo 570 -
2
votes2
answers129
viewsA: How to display id as form counter
I’m sure I understand, but I believe you want something like: //Criar a conexao $link = new mysqli ("localhost", "root", "", "peixaria"); if($link->connect_errno){ echo"Nossas falhas local…