Questions tagged as 'sql'

2
answers

IF WITHIN A SELECT

SELECT @VL_RET_INSS = SUM(VL_RET_INSS), @VL_RET_IRRF = SUM(VL_RET_IRRF), FROM TABELA WHERE VALOR_TABELA > 0 I would like that when the value VL_RET_IRRF was less than 10 the field @VL_RE...
asked by 12.03.2018 / 18:25
2
answers

Perform multiple operations on a single SQL code

I have a table in MySQL as follows and structure: I would like to execute a SQL query that would do the following operations: Total number of records ( total1 ); Count how many records have id_nps_answer between 0 and 6 ( total2 )...
asked by 03.11.2018 / 16:40
3
answers

Insert data Database Related tables

I'm having trouble inserting data that has related tables. $sqlinsert2 = "INSERT INTO tb_detalhe_trabalhador VALUES(0,NULL,NULL,'".$MedicaValidade."',.. Currently the data that is NULL is the fields related to the Table. tb_detail_worker...
asked by 24.02.2014 / 13:24
1
answer

Query to join specific tables

I need to join 3 different tables. But the result I want is: When the reference exists it should join, when it does not exist it should show blank or NULL. My structure: Contact table +------+------------+ | ID | Nome | +------...
asked by 25.07.2016 / 20:12
1
answer

Named database column with alias not found in WHERE clause

I have this SQL query where I need to name the same column datareferencia to anobase and mesbase , as follows. But column error is not found. In my view, after I apply the alias the column happens to exist, but it seems that...
asked by 05.01.2017 / 03:04
2
answers

How to perform more than one select for just two fields from another table

I am not able to select more than one table to display only ID and name data (t_address table), I am performing the SELECT of the entire t_cad table with WHERE in the contract number passed via SELECT from another page: common fields of tables="...
asked by 10.10.2014 / 21:14
2
answers

Indexing views in MySQL

I have a view in my MySQL database, I would like to know if it is possible to index the fields that are contained in it, since I have a group by in it that is consuming a lot, and an index would solve this problem or at least help....
asked by 12.07.2016 / 15:49
2
answers

How to update the surname of a person starting with the initial 'Fabio%'?

It is possible to do this, I have a name of a person who is 'Fábio Mello' and I want to update the name that begins with 'Fábio%' to have the surname '% Borges' how do I make this query? update pessoa set nome = '%Borges' where nome = 'Fabio%'...
asked by 06.03.2016 / 19:15
1
answer

How to perform a procedure with each insert?

When I am going to make a registration I want to, according to the selected category, record an id of the moderator, in the question table. select idcategoria from tb_pergunta select idmoderador,idcategoria from tb_moderador USE [BANCOTESTE]...
asked by 15.06.2015 / 18:32
2
answers

Display multiple records within a single MySQL [duplicate]

I have a question about assembling a select. I have 3 tables that relate M: N as follows: CurrentlyI'musingthissql:selectp.descricao,(selectdescricaofromitemwhereitem.codigo=c.codigoItem)asitemsfromprodutopinnerjoincomposicaoconc.codi...
asked by 04.01.2019 / 20:43