Questions tagged as 'sql'

1
answer

Adding cases to a query

I need to create a query that adds 2 cases , but I can not do it the way I did. If the D3_UM = 'PC' field, it should add the D3_QTSEGUM field. If the field D3_UM <> 'PC' , it should add the field D3_QUANT ....
asked by 27.03.2017 / 15:02
2
answers

How to filter only the date of a field that has a date and time set?

I need to create a select in MySQL to filter the month in a table, but the field where the date is set, has also set the time, like this: [2017-02-04 10:00:00] How do I filter only the date of this field by considering only the month and disr...
asked by 28.08.2017 / 19:58
1
answer

MySQL: Query Table N: N

Create database Banco default character set utf8 default collate utf8_general_ci; use Banco; create table Cadastrados( Nome varchar(50), Sexo enum('M', 'F'), Matricula varchar(9) unique, Curso enum('Arquitetura e Urbanismo', 'Engenharia Ambient...
asked by 21.03.2017 / 16:05
1
answer

A range within another range

I have a problem and I'm looking for the best way to resolve it. I have Min and Max values coming from a database: Ex: id Min Max 1 5 10 2 20 25 3 60 90 4 91 99 If you enter a new Mi...
asked by 04.06.2017 / 23:31
2
answers

Problem with query mysql, what would be the best way to solve

Hello, I'm trying to make an appointment for an ordering system for a restaurant. My tables are arranged as follows: I need to bring all tables (regardless of whether or not they have a request) if they have a request with status 0, such...
asked by 25.01.2017 / 14:47
1
answer

Perform sub-query with data from a first

Hello friends, a question has arisen, where even though I have entered various forums, I have not succeeded in healing it, so see if you can give me a "light". I have a main SELECT, and some sub-queries. In one of these sub-queries I need to pas...
asked by 27.06.2017 / 19:14
2
answers

Select in two tables with data from the first table?

In a table that contains some comments, one of the columns holds the user ID that made this comment, how can I retrieve that user's data with the ID when making a query in the comment table? I know I can do two select one after another, but if p...
asked by 04.12.2016 / 20:18
1
answer

how to get data from one mysql table and insert into another:?

I'm trying to make pincode validator (serial), but I do not know how to do it. I have two tables: "validation" and "expiration". In the "validation" table, it has the following fields: id(int), data(varchar), pincode(varchar), status(int...
asked by 20.11.2016 / 00:10
1
answer

SUBCONSULTATIONS IN SQL?

Using the DB below, how would you return the name of the person you rented on the date '2016/11/17'. Name is in the person table and the date in the loan table. CREATE DATABASE escola; USE escola; CREATE TABLE IF NOT EXISTS acervo ( id in...
asked by 18.11.2016 / 13:24
1
answer

Sort result of a query with JOIN based on the number of records of one of the tables

Assuming I have two tables in my database ( pedidos and pedidos_itens ) how can I get the data from the orders sorted by the orders that contain the most items? I have tried to do a Right Join , but I do not know what to use i...
asked by 17.11.2016 / 13:07