Questions tagged as 'sql'

2
answers

Duplicate select in two tables

I'm doing a system in PHP, but I'm stopped because I can not find the solution to a challenge. I have 2 tables, one call objetos and another call gavetas . I have several names of drawers registered in the gavetas table an...
asked by 16.08.2017 / 19:02
1
answer

How to give a select and play values in the same column

Example: select 'a' as 'letras', 'b' as 'letras' I want to play the letter 'a' and the letter 'b' in the column 'letters', but with this code it returns 2 columns with the same name, but I want to play the values in the same column and I do...
asked by 29.03.2018 / 02:18
1
answer

Signing the last SQL record

I have the following SQL: select cod_nota, cod_local, cod_produto, valor from pedido order by cod_nota,cod_local,cod_produto With the result: |cod_nota|cod_local|cod_produto| Valor | | 501 | 01 | 124714 | 150,00| | 501 |...
asked by 28.03.2018 / 19:42
2
answers

MySQL using variables in select

I have tried a few tutorials but I do not think there is any expectation on how to declare the variable in select by MySQL, DECLARE @idPedido INT; DECLARE @idCombo INT; SELECT @idPedido = idPedido, @idCombo = idCombo FROM Pedidos WHERE idC...
asked by 08.11.2017 / 19:01
2
answers

Duplicate the result of Select Postgresql

I have a record that is a receipt, and in select, I want the line to be duplicated. Ex: Select * from recibos where codigo =1; Result: codigo|cliente|valor|emitente|data 1 Fulano 10 Ciclano 19/10/2017 Result I need: codigo...
asked by 19.10.2017 / 18:44
1
answer

ID of tables out of order

I have a table with 9 records, my identities are in the order of 1 to 9, when I insert a new record in the table automatically a new ID is set, but it is set to the value 30 instead of with the next number which in this case would be 10 (I have...
asked by 10.08.2017 / 14:33
1
answer

How does the process of accessing a database work?

I started to study database and to access a certain database with JDBC you need a driver for each DBMS (MySQL, SQL Server, Oracle), and access is done on disk, but since this process is done? Does DBMS work constantly or only activated when a qu...
asked by 09.08.2017 / 00:57
1
answer

Script for comparing and updating Oracle database equems [closed]

I would like to know if there is any program (or script) that compares schemas and updates in a database, we work with software that uses the Oracle database and every time an update implies changes in the bank schema, we need to also update the...
asked by 24.07.2017 / 19:57
2
answers

How do I list all the fields in a table plus a random value from another table?

I'm having a problem when dealing with two tables, tb_adm_anuncios and tb_adm_anuncio_banner . For each ad I have 4 banners, and to list those ads I need: **Anúncio:** -Nome do Anúncio -Link **Banner:** -Imagem The command...
asked by 27.07.2017 / 16:33
2
answers

Paste previous record - SQL Server 2012

I need to bring only the records where the previous status was 1 , but which is currently 0 . I have a table named solicitação that contains a field called VencimentoPausado , where this field values are 1 or...
asked by 06.08.2017 / 19:57