Questions tagged as 'sql'

1
answer

How to create an index for two tables at the same time in SQL Server?

I'm pretty sure there's no way to do it, come on ... I have the following scenario: (include only key fields for brevity) - Tabela Venda: - id: int; - cliente_id: int; - cliente_tipo: char(1); - Tabela PessoaFisica: - id: int...
asked by 02.07.2018 / 19:18
1
answer

Select fields to return in a SQL INNER JOIN

How do I get into a single SQL statement line, type SELECT * FROM table1 INNER JOIN table2 ON xxxxx , and the desired return would be all fields (columns) of table1 and only one field (column) of table2 ? >     
asked by 25.04.2017 / 16:49
1
answer

How to complement this sql query?

I have the following tables below, where schemas (columns) are described in parentheses and the primary key appears in bold: student ( codaluno , nombrealuno, dt_ingresso, codcurso) course ( coding , coursename) ( codaluno , codturma , ave...
asked by 30.09.2014 / 20:05
2
answers

How to update or insert MySQL in the same query?

In PostgreSQL, I have to use upsert . It checks if the line already exists, if it does, it does update, otherwise it does insert. In MySQL I am not able to do this, I saw some talking to use INSERT ... ON DUPLICATE KEY UPDATE , ho...
asked by 23.05.2017 / 05:42
1
answer

SELECT in VIEW generates subquery?

I would like to know if I make a VIEW with a simple query, if the call of the view generates a new SELECT, that is, a sub-SELECT totalizing 2 SELECTS or if it only points to the SELECT from within VIEW ? I only executed SELECT fr...
asked by 27.07.2017 / 20:07
1
answer

Query - Bring 5 higher records

I have the query below, where I need to bring only the 2 largest columns that have the highest values. Today is coming out like this: Conciliacao Extrato Integração 150 140 80 That is, I wanted to bri...
asked by 02.08.2017 / 23:50
1
answer

Doubt in SQL query ORACLE

I'm thinking of doing a View for report development, and I ran into the following problem. I would like to merge the columns PUBLIC1, PUBLIC2, PUBLIC3, PUBLIC4 into a single column. Eg: AM0173 would have 2 lines ID_3_ETAPA | PUBLI...
asked by 06.03.2017 / 14:22
1
answer

Help with TRIGGER MYSQL [closed]

I need to mount a trigger that before deleting a user it checks if there are any events linked to the user in question, and if it exists, do not allow delete, but never worked with Triggers . Can anyone help me? I have the usuario...
asked by 05.12.2016 / 20:04
1
answer

Grouping SQL queries

I have these queries below, independent, and I'm having trouble grouping them with the same query result, ie leaving the 6 columns requested by select in the same query. SELECT codigo_processo ,nome_produto_processo ,aprovad...
asked by 30.11.2016 / 17:55