Questions tagged as 'sql'

1
answer

Insert in related tables

That's right, I'm not sure how to do this. tb_Customer(id_Customer INTEGER [PK], nm_Customer VARCHAR, cpf_cnpj NUMERIC) dm_address_type(cd_address_type CHAR(1) [PK], ds_address_type VARCHAR) tb_customer_address(id_customer [PFK], cd_address...
asked by 13.05.2018 / 16:30
2
answers

I need to relate two tables in order to bring me a result within the conditions I want

I'm using SQLSERVER Condition (What the result should return me) · Creation of the agenda. It is necessary to create the flow for creation of agenda and blocking to reserve the vacancies; When crossing data from two tables I need to alloca...
asked by 13.05.2018 / 02:28
1
answer

Recover customer orders 1. Duplication ERROR

My code: SELECT Pedido.NumPedido , Pedido.CdCliente , Cliente.Nome , Produto.CdProduto , Produto.Descricao , PedidoItem.Quantidade , PedidoItem.ValorUnitario , PedidoItem.ValorTotalItem FROM Cliente...
asked by 12.06.2018 / 15:18
1
answer

How to update column for each SELECT in a given table?

I tried to create a trigger for a table using it so that it would be activated after every select , but by searching a little I discovered that it is not possible to create triggers for selections, only for update, insert ) a...
asked by 13.06.2018 / 18:49
1
answer

Include column in a select

In my work, I always extract from sql, tables, in one of these tables the extracted information is contracts, date, dial qtde, attendee qtde, alo qtde, and so on. I emphasize that I use Rstudio, with a connection via odbc to extract the base. Th...
asked by 09.06.2018 / 02:37
1
answer

mysql error: each derived table must have its own alias

I am trying to join two tables questionario and resposta and select from the table questionario two dates, this was the code I tried in php: $verificar=mysqli_query($link,"SELECT questionario.*, resposta.* from questionari...
asked by 08.06.2018 / 17:09
1
answer

ORDER BY or LIMIT. What is first processed in SQL Select?

Friends, what is first processed in SQL Select? The "Order by" or "Limit"? For example, if I have a table with multi-state cities. Then I look for cities with more than 100 thousand inhabitants of state X, resulting in 6 cities (eg cities lis...
asked by 07.06.2018 / 09:27
1
answer

Query to count table dependencies

Let's say I have a database with only 50 tables. In the structure, I have several links, several foreign keys. Is there a way, how to make a query that brings up the amount of dependencies of all the bank tables ? For example: Tabl...
asked by 06.06.2018 / 18:01
1
answer

How to return the total quantity when using OFFSET and FETCH NEXT?

I needed to use OFFSET and FETCH NEXT to return a range of data between my query. Table CREATE TABLE [dbo].[Usuario] ( [Id] [int] IDENTITY(1,1) NOT NULL, [Email] [nvarchar](max) NULL, [Nome] [nvarchar](max) NULL, [Sobr...
asked by 27.04.2018 / 01:24
1
answer

Include new table in several Mysql database at one time

I do not know if it would be possible, but we took a PHP / Mysql system from which each client has its own database. But we are creating another tool for this system and of course, it will have a new table in the databases. The problem is that t...
asked by 26.04.2018 / 13:16