Questions tagged as 'select'

1
answer

SELECT on self-relational table [closed]

I have a table funcionario , with attributes: ID (PK) and IDCHEFE (FK of the table itself). Each employee has a idchefe that references another employee (who is their boss). How to make a SELECT that retur...
asked by 18.12.2018 / 01:01
2
answers

Store all records in a table in a variable (PHP)

I need to query my MySQL database and store all rows that are returned within the $dadosBrutos variable. The purpose is for each line to be separated by the character "§", for example: nomeCliente1,telefoneCliente1§nomeCliente2,telefon...
asked by 27.12.2018 / 02:32
2
answers

How to get the value of some select item when clicking on it

In the font given below, the logic fails to capture the click on the select element returning only the first option , and so it appears to be an index problem - selectedIndex . Observe : function selecionar(l...
asked by 10.05.2018 / 17:47
1
answer

Query 2 SQL tables bring all results

I am doing a SQL query to bring users, but I consult 2 tables: users and users_vip No users have all users and users_vip only those that are vip (active or not). When I make my query joining the 2 tables it only brings who has a registrati...
asked by 03.05.2018 / 15:04
4
answers

SELECT with two results

Table: PEOPLE id - nome 1 - BEATRIZ 2 - MARIA 3 - CARLOS 4 - MARIA 5 - JÉSSICA 6 - HENRIQUE How can I make a SELECT that gives me a list with the names sorted by ID descendente , however, a certain NAME first and below the cont...
asked by 19.01.2018 / 12:24
2
answers

Query between tables

I need to make a query as follows: select a jovem that is in the same cidade and estado as mentor and has the largest number of features equal to mentor . My query: SELECT * FROM jovem INNER JOIN ment...
asked by 17.01.2018 / 14:54
1
answer

How to group results of a query?

I have the following query that brings the name of the recipe and the ingredients: $query = (" SELECT r.receita, i.ingrediente FROM ptp_receitas r, ptp_receitas_ingredientes ri, ptp_ingredientes i WHERE r.id = ri.idreceita AND ri.idingrediente...
asked by 12.04.2018 / 22:31
1
answer

Return lower value of a SUM?

I have a SELECT with SUM and would like to understand how do I return the lowest sum value of all values per provider. SELECT distinct fornecedor, cliente, SUM(valor*qtd) AS TOTAL FROM orcamentos WHERE idOrcamento ='$orcamento'...
asked by 06.07.2017 / 15:27
1
answer

Select case in two tables

I have 4 tables: Saida{ id int, idDestino int, idProduto int, tipoDestino int, quant int, data date, solicitante varchar} Paciente{ id int, nome varchar} Unidade{ id int, nome varchar} Produto{ id int, nome varchar, quant int} The sa...
asked by 12.02.2017 / 15:34
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