Posts by Roberto de Campos • 5,345 points
235 posts
-
1
votes2
answers416
viewsA: Comparison of two dates using Mysql varchar type
Convert the field to date on its own SELECT using the function STR_TO_DATE: SELECT * FROM Evento WHERE STR_TO_DATE(data_evento, "%d/%m/%Y") > curdate() ORDER BY idEvento ASC LIMIT 0,3;…
-
2
votes3
answers76
viewsA: How to do sub-consultation with Pdo
You have to use the JOIN to link the two tables and make the comparison: $ranking = $pdo->query(" SELECT * FROM usuarios a INNER JOIN usuarios_emblemas b ON a.usuario = b.usuario WHERE a.banido…
-
1
votes4
answers1471
viewsA: Generate random numbers and add them up
That’s what you need? import random n = 2 total = random.randint(1, 100) + n print total If you need to randomize more than 1 number and add up all the generated numbers, you can do so: import…
pythonanswered Roberto de Campos 5,345 -
3
votes2
answers692
viewsA: How to disable Autocommit in Firedac
You can do it this way: FDConnection1.TxOptions.AutoCommit := False;
-
4
votes2
answers65
viewsA: PHP update com for
Missed the underline and the ; in the end: $valor = $_POST['novo_valor'][$i];
-
2
votes1
answer736
viewsA: Radiogroup select item through a string
Locate the Index through the IndexOf: RadioGroup1.ItemIndex := RadioGroup1.Items.IndexOf('futebol'); Remember that in Radio group only one option will be selected, if you want to select more than…
delphianswered Roberto de Campos 5,345 -
3
votes1
answer1380
viewsA: Copy(Text,1,up to white space)
Use the function POS to return the position of the first character espaço: Copy(Texto, 1, POS(' ', Texto) - 1);
delphianswered Roberto de Campos 5,345 -
0
votes1
answer816
viewsA: Update Trigger in Mysql
You don’t have to do the UPDATE, just set the value: delimiter $$ create trigger Atualiza_Pedido before insert on loja.pedido for each row Begin if new.method = 'metodo' then set new.tipo =…
-
1
votes1
answer150
viewsA: Do not repeat returned Mysqli data
Just put a GROUP BY in hisSELECT: // Fazendo a conexão $conexao = mysqli_connect($this->dbservidor,$this->dbusuario,$this->dbsenha) or die (mysqli_connect_error($conexao)); $select =…
-
0
votes1
answer1014
viewsA: 2 <ion-input> on the same IONIC 2 line
The problem was the tag ion-item out of the tag ion-grid. I just removed it and it worked: <ion-grid> <ion-row> <ion-col width-50> <ion-item>…
ionic2answered Roberto de Campos 5,345 -
2
votes1
answer184
viewsA: MYSQL average per minute
@Jovani, in just one SELECT we can do that. The idea is, we group all the records of the same date, time and minute. Then divide the sum of the currents by the amount of currents in the group:…
-
2
votes3
answers15107
viewsA: How to change the color of the text typed in the input?
Just use color in CSS: <input type="text" style="color: black;">…
-
0
votes1
answer1014
viewsQ: 2 <ion-input> on the same IONIC 2 line
I have a problem in my project with IONIC 2, I need to insert 2 text fields in the same line. I’ve tried to do it using , when I put only text inside it works , but when I put it it does not…
ionic2asked Roberto de Campos 5,345 -
0
votes6
answers1851
viewsA: Interlink two strings into one vector
I couldn’t test it, but probably this way it works: #include <stdio.h> #include <string.h> #include <stdlib.h> void main(){ char s1[30], s2[30], s3[60]; int i=0, tamanho=0, indexS1…
-
1
votes2
answers178
viewsA: Group data from a table
Your SELECT cannot start in the Notes table, you have to start in students, and do a SUB-SELECT for every two months or so: SELECT b.MateriaNome, a.AlunoNome, a.AlunoID, (SELECT MAX(Nota) FROM Notas…
-
0
votes3
answers49
viewsA: Error query by date
Try to do so: DATE(tblacesso.HorarioSaida) = '2017-06-17'
-
4
votes1
answer1010
viewsA: Trigger para update before Insert
It is changing all records because idnotification = idnotified is the same as 1 = 1. in all rows this condition would return true. DELIMITER // CREATE TRIGGER atualizanotificacao BEFORE INSERT ON…
-
2
votes1
answer2460
viewsA: Example of Thread Pool in Delphi
See if this process helps solve your problem: var MinhasThreads: Array of MinhaThread; i: Integer; begin SetLength(MinhasThreads, 0); // Criando as threads dinâmicamente for i := 0 to 9 do begin…
-
0
votes1
answer113
viewsA: Error when creating a Trigger
I believe your problem is with the creation of Trigger, try running this query to create Trigger: DELIMITER $$ CREATE TRIGGER `reposta3A` AFTER INSERT ON `utilizacao_veiculo` FOR EACH ROW BEGIN…
-
1
votes2
answers40
viewsA: Pull the information last information you will use for comparison
To pull the last line you can do this: SELECT Km_Atual FROM Rota ORDER BY Id DESC LIMIT 1;
-
8
votes3
answers9682
viewsA: What’s the difference between Where and having?
The difference is that HAVING is used together with GROUP BY, for example: SELECT a.id, COUNT(a.id) qtde FROM sua_tabela a WHERE a.um_campo_da_sua_tabela = 'um_valor_qualquer' GROUP BY a.categoria…
-
1
votes2
answers1100
viewsA: How to update or Insert in Mysql in the same query?
You can use insert with on duplicate key update. Just create a unique INDEX in your table with the fields you don’t want to duplicate. When inserting duplicate data, Mysql will run UPDATE. Remember…
-
1
votes2
answers1072
viewsA: How to order Record in Delphi (similar to ORDER BY)?
When I go to sort, I prefer to do with WHILE, because we have total control over the iterator. In the case of FOR we cannot change it. var i: Integer; Temporario: TRegistro; begin i := 0; while (i…
-
3
votes2
answers2991
viewsA: SQL for last month and last two months
1)SELECT id, data, lote, modelo, qtd FROM controle_diario WHERE MONTH(data) = ADDDATE(NOW(), INTERVAL -1 MONTH) 3) For the past two months you may have to have some more checking, but this may give…
-
0
votes1
answer89
viewsA: Problem in C triangle check
Your isosceles check is wrong, so it’s not right, the correct would be: isoceles = (((L1 == L2) && (L2 != L3)) || ((L2 == L3) && (L3 != L1)) || ((L3 == L1) && (L3 != L2))); I…
canswered Roberto de Campos 5,345 -
1
votes3
answers227
viewsA: Hyphenate when value is 0 in select
@Eduardo Santos, If you want to exchange the 0 for the hyphen in a select you do so: SELECT IF(seu_campo = 0, '-', seu_campo) AS nome_para_esse_resultado FROM sua_tabela;…
-
1
votes1
answer362
viewsA: Using subselect in oracle. Why is the error occurring?
Missed closing the parentheses after that: kr.DSREGIAOCOMERCIAL AS cod_canal_venda However, you also missed setting a limit, because if your sub query returns more than one line will generate…
-
0
votes2
answers101
viewsA: What can I use to differentiate two POST requests in php
Sends another parameter via post, for example executing, if it is true you execute, otherwise you do not execute.
-
1
votes1
answer935
viewsA: Div when opening is overlapping another div
The div . detailsProduct is with height set at 300px, change this property to min-height:300px.
-
5
votes5
answers15150
viewsA: How to avoid "Cannot read Property ... of Undefined" error?
You can use a recursive function to perform this work in this way: function verificarArrayUnsigned(array){ var isUnsigned = false; if (typeof array !== "unsigned"){ for (var i = 0; i <…
-
0
votes2
answers1533
viewsA: How to bring the typed data and store it in a json to do the processing afterwards?
You do this easily with Jquery using this function: var formdata = $("#meu_formulario").serialize();
-
1
votes2
answers543
viewsA: Pick up data using Join in two table 1 for many
In this case you use the GROUP_CONCAT. Your Query would look like this: SELECT produtos.*, GROUP_CONCAT(grupo_preco_produtos.grupo_preco_venda SEPARATOR ', ') FROM produtos INNER JOIN…
-
-1
votes2
answers147
viewsA: use of mysqli_prepare prevents major sql Injection attacks
mysql_prepare avoids Sqlinjection, since you use parameters in the query. If you use mysql_prepare to concatenate the values of the fields with the query, it will not do any good, however, the…
-
0
votes2
answers42
viewsA: My query that used to work, now does not go to bd at all
Well come on, there are two problems in your query: The id field: Your table is set to prevent records with this null field: id int(11) NOT NULL, and inside the Insert you are not informing this…
-
0
votes2
answers199
viewsA: Compare Sqltimestamp type field
You can use the Isnull property, it would look like this: fDm.fdmEmail.FieldByName('esr_ultimo').IsNull; This property returns true/false.
delphianswered Roberto de Campos 5,345