Questions tagged as 'sql'

2
answers

Sort by the number of repetitions of a column?

In a query in MySql I need to select the results and sort the results based on how much they are repeated using the id_livro column, for example: My comments table: +----------------+-------------+ | id_livro | comentario | +-...
asked by 02.02.2017 / 18:35
2
answers

How to pass data from one table to another SQL

I'm having trouble passing data from one table to another: Example: Table 1 --- > Table 2 --- > delete all information from Table 1 I'm creating the project in VB.NET and using SQL     
asked by 03.03.2015 / 16:18
2
answers

Oracle SQL result ordering

I've done the following query, which was ordered by the product batch creation date. With the migration from version 11 to Oracle R12, the batch field became the migration date, that is, yesterday. As a workaround, we'll use the lote fiel...
asked by 13.06.2016 / 16:14
1
answer

Error with default value for datetime field in MySQL

I had a problem trying to run my database script on the server. The error already gives in the first table that the script generates: CREATE TABLE IF NOT EXISTS 'categoria' ( 'cd_categoria' int(255) NOT NULL, 'titulo' varchar(100) NOT NULL,...
asked by 23.06.2016 / 17:09
3
answers

How can I exclude the penultimate number of a period?

I'm trying to leave the period from 201601 to 20161 in SQL, but I can not do it at all! Can anyone help me? SELECT CONVERT(NUMERIC(5), CONVERT(VARCHAR(4), YEAR(Periodo_Mensal))+ CONVERT(VARCHAR(4), MONTH(Periodo_Mensal))) AS PERIODO...
asked by 01.11.2016 / 20:51
2
answers

How to generate code before entering data in the database

I need to generate a code that is equal to id which will be auto-incremented in the database. It will be a routine that checks the last id generated and generates a code that will be id later before inserting the data. Fo...
asked by 19.11.2015 / 21:40
2
answers

Error inserting data into the database

I'm following php classes, and in the video the guy uses the mysql command, but I know he's old and insecure and I used mysqli , but the code does not display an error, but does not write data to my table, it follows the page...
asked by 16.12.2015 / 16:44
3
answers

How to compare the structure of two SQL Server databases?

I need to compare the DDL structure of two databases, where one is the production bench and the other is the system approval. What tools can be used to do this?     
asked by 24.05.2016 / 17:49
2
answers

SQL Maximum value of another table

I'm doing a course project and I took the last step and would like a little help from you .. The project is a leased SQL database (contract for "rental" of cars.) The tables that import here and the values are: (there are more values, but...
asked by 27.04.2018 / 17:25
2
answers

How to make a NOT IN mysql with 2 tables

I have 3 Person tables, group_materia, Notes, table person has: +------+--------------+-----------+ | id | Nome | turma | +------+--------------+-----------+ | 1 | Aluno 01 | 1 | | 2 | Aluno 02 | 2 |...
asked by 05.05.2018 / 15:14