Questions tagged as 'sql'

2
answers

Sum of values taking into account 3 fields of the table

I have the following table quotations that serves to fetch the totals of several budgets. And each budget has one piece ( part_id ) that can have several works: +---------+-------------+----------+-----------------+ | part_id | al...
asked by 03.03.2017 / 18:23
1
answer

SQL counting data from the second INNER JOIN table, but should not it?

I have 2 tables: sponsors dimensions What I need to do is check how many sponsorships have been nominated but only count the users who have the record in the cotas table. The SQL I made is as follows:    SELECT COUNT(*) A...
asked by 06.03.2017 / 01:07
1
answer

General error error: 1449 when searching MySQL Bank records

I'm getting the error below when doing SELECT: SELECT * FROM vn_horario_view;    SQLSTATE [HY000]: General error: 1449 The user specified as a definer ('root' @ 'localhost') does not exist How do I resolve this error?     
asked by 22.02.2017 / 20:00
1
answer

search all records for the past 12 months including zero

I have my table bud_quotations and I want to fetch all the records that have been inserted in the last 12 months, including months that have no records. Now the count is not working, always returning zero in the count. And what I want...
asked by 02.03.2017 / 16:20
2
answers

MySql select multiple columns from the same table with conditions

I need to select some data from a single table depending on the type of user, for example, an Individual user will have the RG and PIS field while a user will have the state Registration and Fancy name field. I can execute a similar query wit...
asked by 20.06.2017 / 21:07
1
answer

"No database selected" in PHP with MySQL

Columns to receive data: $GravaLinhaBanco = "INSERT INTO 'trechosmonitora_cotacao' ('Codigo', 'CodTrecho', 'CodCliente', 'CodLoja', 'Url', 'Rotulo', 'Trecho', "; $GravaLinhaBanco = $GravaLinhaBanco . "'Origem', 'Destino', 'Tipo', 'Status', 'Id...
asked by 15.02.2017 / 18:04
1
answer

Search for records on a certain day of the week

Personal I have the following select set temp = Conn.Execute("SELECT * FROM tbl_estacionamento ORDER by id asc") I have a table named date where I record the day of the information record, I would like to know how I can only display results...
asked by 25.03.2017 / 11:46
1
answer

Delete Duplicate Records by Group BY

Good morning, Does anyone know if there is a possibility to delete duplicate records as follows: I have a query that brings the result All fields are repeated except the NDO field, and NDOGroup, are these fields that are duplicating the...
asked by 31.03.2017 / 14:26
1
answer

GROUP BY - Display grouped result using WHERE as condition in same table - MySQL

I'm trying to set up a query to fetch results in a table where I need to determine a condition for one column, group for another, and display a third. The database is composed of 6 tables, 5 of which are queried individually, containing: i...
asked by 04.01.2017 / 00:08
1
answer

PostgreSQL - Inserting data into tables linked by Foreign Key

Hello I have a data insertion problem in tables linked by foreign keys. I have read in some places that there is a "with" command that helps in these situations, but I did not quite understand how it is used. I would like to put together f...
asked by 11.01.2017 / 06:30