Questions tagged as 'sql'

2
answers

Two Results in one query [closed]

I have the following example, two related tables Tabela SETOR SetorID [chave] Setor Vagas Tabela FUNCIONARIOS FuncionarioID[chave] SetorID[chave estrangeira] Nome Funcao CargaHoraria I would like to do a SQL query filtering by Sector ID...
asked by 28.11.2016 / 20:42
1
answer

How to create a Trigger for a specific column of a table?

I created a trigger for my X table, for the purpose of making a update record that runs on this table. For each update in the X table, modified (old) values are stored in the Z table. PROBLEMATIC : The X table has several...
asked by 20.12.2016 / 12:36
2
answers

Multiple if in an SQL condition

I'm trying to use 2 if s but the result always returns empty, when I use only if it will. SELECT aci_codigo, aci_valor_pagamento, bai_fk_pes_codigo, aci_tipo_pagamento, aci_fk_ftm_codigo, aci_nosso_numero, ftm_descr...
asked by 02.12.2016 / 15:07
1
answer

SELECT to filter null value? [duplicate]

I'm trying to make a SELECT in a conta table, in this table I have a foreign key for the venda table, in certain cases this foreign key is null and I want to return the information of the sale when this key i...
asked by 30.10.2016 / 01:17
1
answer

Return value entered after performing INSERT

I have a following table: CREATE TABLE tblUser ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid VARCHAR(24) NULL, name VARCHAR(256) NULL } I'm inserting a uuid random so that it's a unique identifier directly inside my databa...
asked by 10.12.2016 / 14:40
1
answer

How to insert data into another table from the foreign key?

I have a table in my database called imoveis where I have some columns in it, highlighting localizacao_fk and correspondencia_fk , both foreign keys that reference the enderecos table. What I want to know is how to ins...
asked by 04.11.2016 / 04:30
2
answers

SQL Syntax Error in creating FK

I want to add a foreign key in the CONSULT However, MySql reports the following error:    1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'REFE...
asked by 06.11.2016 / 20:52
1
answer

Case for various fields

Can I make a query using 1 case for multiple fields? The fields are of type int . If not, can I do it in php? Query select *, (case (pergunta1,pergunta2) when 1 then 'Ótimo' when 2 then 'Bom' when 3 then 'Regular' w...
asked by 07.11.2016 / 11:51
1
answer

Relationship between tables n for n

I'm creating a small project and I'm having a question. Suppose I have a certain types of coffees, these coffees can be served in more than two cup sizes. Since the relationship between tables is from n to n , we have the following tables:...
asked by 23.12.2016 / 05:46
1
answer

Searching for data from an ID in DB

I have researched here and google to see if it would solve my problem without having to ask a question, but I could not find any solution. What I'm trying to do is create a "related" but without it displaying the same post or video in case. I...
asked by 24.10.2016 / 13:19