Questions tagged as 'sql-select'

1
answer

How to group by month with SQL?

I have a table, for example, with an attribute nome and data (for example only). I would like to generate a query that returns the quantity of each row grouped by name and month: Nome Janeiro Fev Março Abril Maio ... João 1...
asked by 15.05.2014 / 22:42
2
answers

SQL Server - Check duplicate data in two concurrent fields

DBMS: SQL Server 2014; Problem: I need to know which records are duplicated, so that the verification is done in two simultaneous fields, ie if the field "CPF" with the value '83971465842' and the field 'MAT' with the value ' 001 'exists, in...
asked by 25.06.2014 / 22:39
3
answers

How to create search in MySQL that returns unmatched rows?

I'd like to know how I can do a search that returns records that are not part of the search condition. For example, consider the situation where there is a database of a movie store with the cliente table and the aluguel table....
asked by 24.01.2016 / 05:18
3
answers

No select error using mysqli_query

I've done a php to list the rooms, but I'm having difficulty listing them, if anyone can help me, I would appreciate it. <?php $link = mysqli_connect("localhost","root","","hotel"); $result = mysqli_query("SELECT descricao FROM quartos WHER...
asked by 08.06.2015 / 21:53
2
answers

How to sum values from a grouped field by date?

SELECT funcionario_id, data, avaliacao_postura FROM equipe id funcionario_id data avaliacao_postura 1 1 2014-03-02 -25;-10;-5;-12 2 1 2014-03-01 -25;-10;-18...
asked by 10.04.2014 / 00:43
2
answers

How to get random results in SQL with different SGDBs?

Based on this existent question in SOen and wanting to bring interesting and useful content to SOpt I ask this question: How to get random results in SQL with different SGDBs?    I'm leaving a ready answer, but I'm going to leave it open...
asked by 26.04.2018 / 17:47
1
answer

Perform RANDOM SELECT [duplicate]

I have a table where I always want to display a single record in a random fashion. I'm doing this: SELECT 'id' FROM 'tabela' ORDER BY RAND() LIMIT 1 I see that in this way the same records repeat a lot, is there a better way to do it?...
asked by 18.01.2016 / 10:21
1
answer

Error with sql Like

How do I extract all fields beginning with '1.' from the database? In my statement I used LIKE but it did not have any return, but if I remove the point it already returns something, but it returns fields that I do not want, eg 10.1; What's wron...
asked by 02.12.2015 / 11:02
1
answer

Relate two mysql tables with data from the same column?

I'm creating a 2014 cup table. I created two tables. times (ID, nome, sigla, bandeira) jogos (ID, fase, local, time1_id, time2_id, data) I have a relatively simple problem, but I did not find a search solution ... I want to make a Selec...
asked by 10.06.2014 / 22:10
8
answers

Why is "SELECT * FROM table" bad?

It is often said that getting all the columns of a table through the SELECT * FROM tabela command is bad practice. Any recommendations without explanation are not helpful. So ... If it is bad practice, there must be a way to use it pro...
asked by 16.06.2014 / 21:26