Posts by rLinhares • 7,797 points
331 posts
-
0
votes4
answers1139
viewsA: How to get last login of each user using mysql?
I don’t know what your concern is with performance, but I don’t think a consultation like this would have a considerable loss using union; if I understand correctly, you want the last login with and…
-
1
votes2
answers1349
viewsA: Query to list number of occurrences
The way it is query will only return if the person has more than once the same category. To list the number of categories per person, you need to not group by category: SELECT COUNT(*), PESSOA_FK…
-
21
votes3
answers2676
viewsQ: When to use SET and SELECT?
I know that as in virtually all issues related to "either" there must be situations where it is best to use SET or SELECT, in a Procedure (for example). At work we always wear the same SELECT, even…
-
0
votes3
answers1241
viewsA: Statement Where comparing Date(type date) variable with current date
I believe your problem is that you’re validating the full date. As you just want today’s date, make the comparison by formatting the dates to ignore hours: select inst_name, dateTime from…
-
2
votes1
answer1268
viewsA: What is Crow’s Foot about the database?
Crow’s Foot (Crow’s Foot): This is the most widely used notation among data architects. Its implementation is made through rectangles representing entities, lines representing the relationships and…
-
1
votes3
answers97
viewsA: How to write times on console entries without repeating too much code
Create a method that receives as parameter the message you want to print: public void ExibirMensagem(string msg) { Console.WriteLine("[{0}] - {1}", DateTime.Now.ToString("HH:mm:ss:fff"), msg); } So…
-
0
votes1
answer121
viewsA: To create a list where you list all existing items within an order
I believe you need to use the Environment.Newline instead of /; do not know how is your data display structure (if it has some formatting), but should work. Session["itemPedido"] =…
-
0
votes1
answer40
viewsA: Error updating given with condition
By your description there is no problem with your code, but rather a certain confusion in the understanding. Its validation says valor should be updated with the value of the same case caminho is…
-
1
votes3
answers3370
viewsA: How to convert Date to whole in Java?
I understand you want a different format but in this answer the parameter in the creation of the SimpleDateFormat does not contain bars (hence the "generated date" does not); tries to create so:…
-
3
votes3
answers8795
viewsA: How to round a number to the highest value in Mysql?
Use the function Ceiling(x)?? SELECT CEILING(1.23); //retorno: 2…
-
1
votes3
answers3361
viewsA: How to convert 0 to null (Error inserting NULL into an INT field from a variable)
I believe that’s possible, yes. In that reply has something like what you want: INSERT INTO etc(campo1, campo2) VALUES ( (CASE campo1 WHEN '' THEN NULL ELSE campo1 END), (CASE campo2 WHEN '' THEN…
-
1
votes2
answers686
viewsA: Youtube video popup
I don’t know if this could be it but right at the beginning you’re creating a tag inside another: <a <label onclick = "PopupCenter('https://www.youtube.com/embed/INQcOCgpOXs','785','680')"…
-
3
votes2
answers371
viewsA: Add + 1 to current number (Jquery)
The parameter must be arriving in the function novo_id(lista) as string. Uses the function parseint before the sum: function novo_id(lista) { var id = 0; //console.log(id); if (lista.length > 0)…
-
1
votes3
answers6300
viewsA: How to add numerical values inside a C string?
In C# you can use the Convert.Toint16: string digitos = "123456"; string retorno = string.Empty; int total = 0; for(int i = 0; i < digitos.Length; i++){ total += Convert.ToInt16(digitos[i]); if…
-
0
votes2
answers990
views -
0
votes2
answers25
viewsA: Difficulty mounting query for Search in multiple columns
Admitting that your columns store the string of characters (carac_a, carac_b, etc) will always receive some of the possible searched values (aaa, bbb, etc), you need to consult if any of the columns…
-
0
votes2
answers1856
viewsA: list index out of range Python
I believe the error is in the second part of the validation (y[i]==''); the for goes up to the maximum size of the x, as you said, but if the y is minor, you will receive this error. If you really…
-
0
votes1
answer54
viewsA: Connection error mysql_query
You reversed the order of the parameters. res=mysql_query("INSERT INTO user(CPF, name) values('"+CPF+"','"+nome+"');", &connection); According to the documentation, the Resource comes as second…
-
2
votes3
answers2812
viewsA: How to convert a string to boolean?
Compare the string you want to validate with true: var texto = 'false'; var valBool = texto.toLowerCase() == 'true';
-
2
votes1
answer577
viewsA: Zeros on the left
I believe that the Padleft would solve for your case: Dim pad As Char str = "11" pad = "0"c Console.WriteLine(str.PadLeft(11, pad)) Another possibility found in this answer:…
-
2
votes1
answer1122
viewsA: "String index out of range: 5"
The problem is yes in yours for (and it would happen in both). for (int i = 0; i < 5; i = i + 2) You say he should iterate while the i is less than 5; has the user type 4 numbers. Right away it’s…
-
0
votes7
answers412
viewsA: Mount an sql query filtering data
You need to filter items with status "EXCLUDED" (as it is already doing) and also with nf other than "000002": SELECT id, nf, status, data FROM documentos WHERE status LIKE ('%EXCLUIDO%') and nf…
-
0
votes1
answer80
viewsA: How to cancel action with key
I found your question very confusing, but from the comment you made, I think you want something like the code below: string text = string.Empty; do{ Console.WriteLine("Digite algo"); text =…
-
7
votes3
answers8992
viewsA: Select first record within a segmentation in SQL Server
Interesting question. I searched and found that answer: ;WITH cte AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY codigo_curso ORDER BY data_ingresso DESC) AS rn FROM tusu ) SELECT * FROM cte WHERE…
-
0
votes2
answers2116
viewsA: Format Angularjs date
Try that code (javascript): function time_format(d) { hours = format_two_digits(d.getHours()); minutes = format_two_digits(d.getMinutes()); seconds = format_two_digits(d.getSeconds()); return hours…
-
0
votes3
answers1147
viewsA: What is the difference between . on('input') / . on('Paste') / . on('change')?
The basic difference is that the oninput is fired whenever the user enters any value in the field, while the onpaste is only when the user "glue" some information.…
-
2
votes1
answer451
viewsA: SQL command in MYSQL
The error is where you mount the CHECK, doesn’t need the valor_Venda IN: CREATE TABLE produto( Cod_produto int primary key not null, nome_produto varchar(50) NOT NULL, descricao text,…
-
-1
votes3
answers1560
viewsA: Insertion of the letter "e" in type number
I found something similar in that reply: var valorNum = document.getElementById("id_input") valorNum.addEventListener("keydown", function(e) { // prevent: "e" if ([69].includes(e.keyCode)) {…
-
1
votes2
answers1443
viewsA: How to make a nested FOR?
You need to take the print that displays the value of the first loop from within the second: for item in lista: i = 0; print(item) for linha in arquivo: if item[0:-1] in linha: i += 1 print(i) So it…
-
0
votes2
answers125
viewsA: Doubt regarding Count in SQL command
I don’t know if you would have much impact on performance but you could do two selects and use Union: SELECT COUNT(codigosuprimento) quantidade, codigosuprimento FROM public.estoque WHERE usado =…
-
1
votes2
answers457
viewsA: Why doesn’t my while work?
Your stopping condition is as follows: while sexo != 'f' or sexo != 'm':, that is, when the user type something other than 'f' or '’m', it remains in the loop, and he will never type a letter equal…
-
1
votes2
answers49
viewsA: Update table field with information from another column
Being the same table you won’t need to Join or something like that; just know the update condition, in case the id of the item that will be updated (idVendaEfetuada): UPDATE tabela_vendas SET…
-
5
votes4
answers10900
viewsA: Is it possible to use the ternary operator under several conditions at the same time?
It’s even possible, but it’s pretty tricky to tell the truth: echo ($ativa == 0) ? "Médico(a) Desativado(a)" : (($ativa == 1) ? "Médico(a) Ativo(a)" : "Informação Indisponível"); In fact you add a…
-
6
votes3
answers370
viewsA: Private set of property in an interface
The safest is you set just get; with this whoever implements the interface will have no option to change the value. public interface IBar { string Id { get; } } Who implement the interface will be…
-
-4
votes2
answers229
viewsQ: Validation of javascript / jquery object?
I lost a little time with a validation in javascript and I got the doubt in my head: I need to know if an element exists through id. I tried a few ways and I was unsuccessful: //tentativa 1…
-
1
votes3
answers525
viewsA: Login without differentiating between capital letters and minusculas?
The simplest way would be convert the strings before comparison: $result1 = "SELECT * FROM users WHERE UPPER(username) = UPPER('$Name') && userpass = '$PassMD5' LIMIT 1";…
-
1
votes2
answers1323
viewsA: Bring results equal to 0 as blank value in a query in SQL Server
I don’t know if you’ll find gambiarra but you can check if the return is 0 and return empty: select F.C37 [Pontuação], CASE WHEN ISNULL(count(distinct TD.UsuIDCliente),'-') = 0 THEN '' ELSE…
-
0
votes2
answers207
viewsA: Show a dialog with jQuery?
Via javascript you can try $('#my-dialog').modal('show');. Look that answer if you need.…
-
2
votes3
answers3392
viewsA: _ (underline) in consultation with LIKE
I’ve been there, I’ve come up with my solution of that answer. SELECT * FROM mytable WHERE LOWER(REPLACE(post_code_field, ' ', '')) = LOWER(REPLACE(?, ' ', ''))…
-
2
votes2
answers40
viewsA: Make div appear and others disappear with a single click
I suggest you add a class to Divs, hide everything in click and display only the specific: <div id="acre" class="estado" style="display:none"></div> <div id="amapa" class="estado"…
-
1
votes2
answers193
viewsA: How to delete both duplicate values from the array?
You can use array_intersect and update old arrays: $array_antes = array_intersect($array_antes, $array_concatenado);…
-
0
votes3
answers1142
viewsA: Remove whitespace when counting Javascript
Use the replace to remove the spaces: function contar() { var textoSemEspacos = document.form1.txtTexto.value.replace(' ', ''); var num_caracteres = textoSemEspacos.length;…
javascriptanswered rLinhares 7,797 -
1
votes4
answers123
viewsA: How to check if one String completes another?
It would be an option to use index and do its own function? function ContemString(str1, str2){ return str1.indexOf(str2) > -1; }…
-
1
votes1
answer166
views -
3
votes5
answers12287
viewsA: How to perform SQL concatenation
Uses the function CONCAT. SELECT CONCAT(YEAR(OrderDate), '-', MONTH(OrderDate)) AS Year_Month FROM sales.SalesOrderHeader In this case, the second parameter of the Concat is the separator ('-') that…
-
1
votes3
answers69
viewsA: I have this cursor and the Where 'between' gives error. I wanted to select the years 2005 to 2008
I believe your error is really syntax; use the between as below: WHERE year(OrderDate) between '2005' and '2008' NOTE: Notice that the two times you use the between error happens, then corrects at…
-
0
votes3
answers77
viewsA: How do I link three tables?
Substitur the INNER JOIN for FULL OUTER JOIN will solve your problem.…
-
1
votes3
answers895
viewsA: Return Id’s That Are Not in Database - MYSQL
Try this solution: I played them all ID which exist in a temporary table with the status of "exists"; then, with a counter, checks who does not exist and adds with the status of "there is no". DROP…
-
2
votes4
answers774
viewsA: Concatenate variables from an array
To make it more general, try the loop thus: $filiais = ''; foreach ($array_filial as $key => $f) { if ($filiais != '') $filiais .= "+ "; $filiais .= $f; }…
-
1
votes1
answer137
viewsA: Filter data by period
Actually you need that obligatorily the date is between the two defined; then the select would look like this: SELECT * FROM anuencias WHERE (status like '%ASSINATURA%' OR status like '%PRONTA PRA…