Posts by Sorack • 27,430 points
864 posts
-
1
votes3
answers1269
viewsA: Get file folder with Nodejs
Use the function path.basename: const path = require('path'); // __dirname = C:\desenvolvimento\amostra // __filename = C:\desenvolvimento\amostra\amostra.js const diretorio =…
-
1
votes2
answers97
viewsA: LEFT JOIN com having
In case you don’t want the field of LEFT be required you can check if it is not NULL first: ... WHERE (chave_tabela_left IS NULL OR campo_tabela_left = 'VALOR DESEJADO') ...…
-
1
votes6
answers6000
viewsA: How to get the column properties of a table?
Use the table COLUMNS of information_schema: SELECT column_name, data_type, character_maximum_length FROM information_schema.columns WHERE table_name = 'tabela' AND column_name = 'coluna'; COLUMNS…
-
2
votes2
answers265
viewsA: ORDER BY Mysql - Reporting organisation
From the version 8 of MySQL you can use the function ROW_NUMBER as follows: Schema (Mysql V8.0) CREATE TABLE contact ( id INTEGER PRIMARY KEY AUTO_INCREMENT, contact VARCHAR(100) ); INSERT INTO…
-
2
votes1
answer142
views -
3
votes1
answer297
viewsA: Return value from inside fetch
It turns out that the fetch returns a promise and, therefore, you can use the value using the then or await and not directly: function fetchDictionary() { const URL_TO_FETCH =…
-
0
votes2
answers58
viewsA: Help Require Node
The Node is a different context from your client page. The require by itself works only on Node. To use on the customer you only need to import the axios in his HTML: <script…
-
1
votes1
answer450
viewsA: Competing requests using Xios without losing the session
You can use a module that supports cookies in his axios, such as the axios-cookiejar-support. axios-cookiejar-support const axios = require('axios').default; const axiosCookieJarSupport =…
-
3
votes1
answer461
viewsA: Comment on Mysql table
You can add a comment in the table by changing it: ALTER TABLE tabela COMMENT = 'Comentário da tabela'; And you can read the comment with the following query: SELECT TABLE_COMMENT FROM…
-
3
votes3
answers1436
viewsA: SQL - Two different WHERE conditions for the same SELECT
Use the OR: WHERE (@show = 1 AND d.statusId = ds.id) OR d.statusId != 3;
-
0
votes1
answer97
viewsA: Simplified Javascript Cookie Value Capture
By adapting the code of the solution next to what you want, you can use the split to catch the last occurrence of / and the timer can be added with setTimeout: setTimeout(function() { var partes =…
javascriptanswered Sorack 27,430 -
3
votes1
answer141
viewsA: How to determine a gap condition between records?
You can use variables to control which date will be used base. Schema (Mysql v5.6) CREATE TABLE tabela ( data TIMESTAMP, valor INTEGER ); INSERT INTO tabela(data, valor) VALUES('2019-01-04…
-
23
votes7
answers620
viewsQ: How to access a circular array?
Whereas I have a array: const a = ['A', 'B', 'C']; I would like to create a function that returns an item and, with each call, returns the subsequent one, and when it comes to the end, returns the…
-
1
votes1
answer23
viewsA: Return message using declare?
The MySQL does not have print. Instead make a SELECT of your variable: SET @nome = 'NOME'; SELECT @nome;
-
2
votes1
answer46
viewsA: GET complex in Node.js API
You can do with query even, its route will only be identified as GET of a specific product if you send information after the bar. As is not the case will enter the first GET that brings all…
-
0
votes1
answer29
viewsA: QUERY MARIA DB TO FILTER CURRENT TIMESTAMP ONLY
Use a GROUP BY the first three columns and a MAX to catch the biggest TIMESTAMP: SELECT DISTINCT h.name as "Unidade de Negócio", CASE WHEN s.acknowledged = 1 THEN a.comment_data ELSE 0 END AS…
-
0
votes2
answers427
viewsA: Web automation with Selenium or other tools without opening the nagevador?
There is a library of Nodecalling for Puppeteer for automation purposes. Puppeteer Most Things that you can do Manually in the browser can be done using Puppeteer! Here are a few examples to get you…
-
5
votes2
answers58
viewsA: Bring records that is not in another table
Create an index for your table: ALTER TABLE quiz_resolvido ADD INDEX quiz_resolvido_index (id_usuario, id_quiz); More information on the answer to the question Indexes in Mysql queries and What is…
-
0
votes1
answer505
viewsA: Check if date is valid in Mysql database
You can use the function WEEK to check if a date string is valid. I’ve mounted an example below. Schema (Mysql v5.7) CREATE TABLE dias ( descricao VARCHAR(10) ); INSERT INTO dias(descricao)…
-
0
votes1
answer625
viewsA: Error converting varchar data type to float
To concatenate a numeric type to a text you must convert it to text, otherwise the database will try to perform a sum: SET @comando = 'UPDATE ' + @NomeTabela + ' SET ace_ cracha = ' +…
-
0
votes2
answers83
viewsA: Read JSON with JS
Adjusting the answer to the question JSON Challenge with JS to work with the series in the key terms the following: const dados = [ { cnpj: '1234567891011', serie: '1', numero: '1' }, { cnpj:…
-
2
votes1
answer8888
viewsA: Concatenate columns in SQL SERVER
SELECT TA.asset + '' + TA.techCharacteristic + '' + TA.VALUE + '' + T.meterUnit AS COLUNAS FROM AssetTechChar AS TA INNER JOIN TechCharacteristic AS T ON TA.techCharacteristic = T.techCharacteristic…
-
1
votes2
answers65
viewsA: How does this Join look properly?
Change the column COD_SITUACAO_FK for SITUACAO: SELECT tbEquipamento.TIPO_EQUIPAMENTO, tbEquipamento.NUMERO_SERIE, tbSituacao_Equipamento.SITUACAO, tbEquipamento.NUMERO_ATIVO FROM ((tbEquipamento…
-
1
votes1
answer483
viewsA: Sorting 2 Columns at the same time SQL Server
You just need to use the ORDER BY according to the priority: ORDER BY w.service_req_id, w.to_time SELECT - Clause ORDER BY Sorts data returned by a query on SQL Server. Use this clause to: Classify…
-
1
votes2
answers74
viewsA: SQL query, count the amount of existing values of a Foreign Key for each corresponding Primary Key in 1 query
The GROUP BY in his query and you can use a JOIN instead of putting all tables in the FROM: Schema (Mysql v5.7) CREATE TABLE admin ( id_admin INTEGER, email VARCHAR(100), password VARCHAR(100) );…
-
3
votes2
answers68
viewsA: Why is the prompt run anyway in javascript?
Window.prompt() Window.prompt() displays a dialog box with an optional message asking the user to input some text. Syntax resultado = window.prompt(texto, valor); resultado is a string containing…
javascriptanswered Sorack 27,430 -
0
votes2
answers206
viewsA: Mysql - auto increment shared between tables
I point you to use a link table and put the AUTO_INCREMENT in this table with foreign key for the other two. In each of the main tables you would create a TRIGGER which would fill the link table at…
-
1
votes1
answer56
viewsA: JSON Challenge with JS
You can organize your array initial with the function reduce transforming into an object with its respective items. After that, traverse your organized object discovering the minimum and maximum.…
-
1
votes1
answer68
viewsA: Merge results in mysql
You can control the state of your columns by means of variables, but it is difficult to read with so many variables and there is probably a better way that could be discovered if more information…
-
2
votes1
answer33
views -
0
votes3
answers36
viewsA: Redirect when you have a page click event
You need to pass the instruction body for your jQuery to say what type of element will receive the listener: $('body').on('click', function() { window.location.href = "http://..."; }); <script…
javascriptanswered Sorack 27,430 -
0
votes1
answer232
views -
1
votes1
answer122
viewsA: Insert ID into another field of the same table at the time of INSERT
Create a TRIGGER AFTER INSERT to accomplish a UPDATE: CREATE TRIGGER new_loaner_added AFTER INSERT ON usuarios FOR EACH ROW UPDATE usuarios SET id_membro = NEW.id WHERE id = NEW.id; TRIGGER A…
-
3
votes3
answers100
viewsA: Problems with array manipulation to find result
Use a while with the output condition by checking the size of the array resulting. Within the while order the array using sort. Take the first 2 values from array using shift and ensuring that they…
-
0
votes1
answer58
viewsA: How to find all places where depreciated methods are being used in Netbeans?
Open the properties of your project, go to the option Compilação within the option Construir in the tree on the left side. In the field Opções Adicionais do Compilador insert -deprecation. After…
-
1
votes2
answers120
viewsA: Oracle SQL - Return of the first record between two dates
Use the clause EXISTS together with NOT: SELECT p.codigo_usuario, p.data_producao FROM tbproducao p WHERE p.data_producao BETWEEN TO_DATE('01/02/2013', 'DD/MM/YYYY') AND TO_DATE('30/03/2013',…
-
2
votes2
answers403
viewsA: Read JSON Key with Javascript
localStorage saves a string then to save you must do the following: localStorage.setItem('dados_usuario', JSON.stringify(dados_usuario )); And to read: const dados_usuario =…
-
7
votes3
answers839
viewsA: how to select zero Count
You should search the main table data municipio to ensure that some line will return. After that make the link with LEFT JOIN on the table cliente and then perform the COUNT column-based cliente.id…
-
5
votes1
answer45
viewsA: stacked arrays
You can create a method that goes through your items array and: If you find an element, add the array of origin to the result; If you find a array, Scroll this to see if you have others arrays or…
-
4
votes1
answer60
viewsA: Merge Objects that have some similarity
You can use the function reduce of array to scroll through each item and check if it is already in another array results (which will be populated within the reduce). const exemplo = [ {'Title':…
javascriptanswered Sorack 27,430 -
3
votes1
answer203
viewsA: Return Array inside the other
You have some problems in your execution: There is no mention of the value in the first execution of the variable parent; No mention of variable value user; Submenu completion is asynchronous, and…
-
1
votes1
answer57
viewsA: Print days of the month in the table
The best way to do what you want would be directly in the programming language that is generating the report. But in the bank you can create a function that generates a record for each day of the…
-
5
votes3
answers1301
viewsA: How to catch the element where my cursor is?
Use the event onmousemove in the body: var atual = null; function mouseEventHandler(mEvent) { var ultimo = atual; // Internet Explorer || Demais navegadores atual = mEvent.srcElement ||…
-
5
votes1
answer57
viewsA: select with order by
You can get this result in a simple table like this? Not Is there any hidden index that can do this order by? Not From the SQL Server 2007 you can use a column IDENTITY. Change your table and add a…
-
2
votes1
answer199
viewsA: Promises Sequential - Node
The problem is that you are only running the function without returning the promise of the subsequent function. Then you can change your code to: // ... Promise.resolve(pedido.isEntregue())…
-
2
votes1
answer223
viewsQ: The Object 'XXXX' is dependent on column 'XXXX'
When I try to change the type of the primary key of a table, I get the following error: The object 'XXXX' is dependent on column 'XXXX'. I would like to know how to "less" manual fix this error…
-
3
votes2
answers1108
viewsA: Command to set a default value for a column in SQL Server
To set a default value of a table column you must use the operator DEFAULT. You can inform you when creating your table: CREATE TABLE tabela ( id INT NOT NULL PRIMARY KEY, coluna1 VARCHAR(100),…
-
1
votes1
answer50
viewsA: Return database value to e-mail
Its function nomes is async, that is, it returns a Promise. So to use it you must use the operator await: const mailOptions = { from: '[email protected]', to: '[email protected]', subject: 'Email…
-
0
votes1
answer107
viewsA: Restore dump with nodejs
In the Node.js you can run an external application. In this case we will use the module child_process to execute the psql and dump the contents into the new bank: const { spawn } =…
-
7
votes4
answers4763
views