Questions tagged as 'sql-select'

1
answer

android.database.sqlite.SQLiteException: near "SQL": syntax error (code 1):, while compiling: SQL * FROM Employers WHERE id =?

I'm trying to make SELECT below passing a value as a parameter in the search, but it still gives the same error.    android.database.sqlite.SQLiteException: near "SQL": syntax error (code 1):, while compiling: SQL * FROM Employers WHER...
asked by 09.11.2018 / 07:32
1
answer

View most current record sql server 2008

I am trying to fetch only the last record (last sale) from each client and I am not succeeding. I've tried it in many ways, but nothing .. Just returns all sales from the date. Follow my query. Thanks for the help. use banco select m.cli_forn,...
asked by 19.09.2018 / 21:45
1
answer

Select does not return repeated based on a column

I came across a situation where I have a client registry that can have more than one address in the related tbEndereco table and an address can belong to more than one client. But when I query clients I need to return only 1 of those addresses,...
asked by 25.07.2018 / 12:31
2
answers

Problem inserting data into a table containing foreign keys

Hello, everyone! Well ... My problem is this: I have a MySQL database that has 3 tables (Client, Event, Equipment). The event table has two foreign keys, the first one referencing the id of the Customer table (customer_id) and the second re...
asked by 30.07.2018 / 03:46
1
answer

How to select and assign the quantity

I'm trying to use mysql to select two tables and assign the number of rows to a field eg I have two tables : Group, Person I want to make a join in the Group table that shows the number of people assigned to this group through the Gro...
asked by 01.02.2018 / 17:51
1
answer

Select result, and only show if all are equivalent

I'm servicing a database, and I have the following situation; in the database I have 5 columns in a table, they are:    ID (PK) | IDBillet | Result | Borrowed | Date | I have to filter for the user to see, only the IDBilhete that is missi...
asked by 01.02.2018 / 15:34
1
answer

How to select multiple data from related tables

I have created three tables in the student, book and loan database, I would like to list all the books that were loaned to each student, however, when the student takes more than one borrowed book the command I use to make the search in the bank...
asked by 19.06.2017 / 00:19
3
answers

Compare data from two tables

I have two tables: Tabela1 Tabela2 +------+----------+--------+ +------+----------+------------+ | id | idCidade | bairro | | id | idBairro | logradouro | +------+----------+--------+ +------+----------+------...
asked by 31.05.2017 / 19:38
1
answer

Return average cost between partially equal products

As I exemplify in SQL Fiddle , I need to give the tables the data to be returned as follows: / p> nome | descricao| tipo | custo| ult_lancamento | entradas | saidas ---------------------------------------------------------------...
asked by 16.05.2017 / 01:27
1
answer

Select with max (date), penultima (date)

I have a table with product code and date of sale. I would like to make a select picking the product code, the date of the last sale and the date of the next-to-last sale with group by code. Is it possible? select p.codigo, max(date_format(p...
asked by 13.01.2017 / 14:21