Most voted "select" questions
USE THIS TAG ONLY WHEN REFERRING TO DATABASE. SELECT is an SQL statement that returns zero or more rows, from one or more base tables, temporary tables, or views in a database. DO NOT USE to refer to the HTML "select" element, in which case use [html-select].
Learn more…807 questions
Sort by count of
-
1
votes2
answers865
viewsSelect to know customers without service in the last 30 days plsql
I have the following columns: CODCLI, CLIENT AND DTULTCOMP I need to know which customers you haven’t bought in the last 30 days. the DTULTCOMP column is in DATE format Table: PCLIENT
-
1
votes2
answers159
viewsQuery mysql problem, what would be the best way to solve
Hello, I am trying to make a query for an order system for a restaurant. My tables are arranged as follows: I need to bring all tables (regardless of whether they have a request or not) if they have…
-
1
votes1
answer38
viewsList tables to make recommendations to the customer?
I have a table "likes", "commented" and "visited", each time a user likes, comments or visits a particular book on my page a record is inserted in the database for such: Table likes:…
-
1
votes1
answer293
viewsHow to count how many fields are empty in the mysql table
I have a land register table with several columns (some of them: id, address, city, proposal, etc) and I would like to count how many fields are empty. For example, the table has a total of 44…
-
1
votes1
answer187
viewsDifference between normal avg and using case when in Mysql
I have two queries that are supposed to give the same result, however it is not happening. Can someone explain to me why it is not displayed even result? Query that returns me the expected result:…
-
1
votes1
answer526
viewsSelect 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…
-
1
votes1
answer377
viewsFilter dynamic table (Power Pivot) by Listbox
This code: /a/309087/116347 Make the selection in Listabox ... and Filter activated by a button.. as described in the link... But if the Dynamic Table is created by Power Pivot .. This code does not…
-
1
votes3
answers616
viewsFirst leave selected select item
Good afternoon, everybody, how are you? Next, I’m listing some courses with v-for and it goes well, however, option needs to be selected and I would like the first item of select to already appear…
-
1
votes2
answers62
viewsMYSQL: sort by specific Rows within SELECT
I’ve been trying to figure this out for three days and I haven’t found the answer anywhere I have a table in the database where I need to do a SELECT on all products but they need to be sorted…
-
1
votes1
answer446
viewsSelect a row where a column has an element of a CSV
I have a table in the database with the following structure: +---------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra |…
-
1
votes1
answer44
viewsSelect a list of values and from that list, select the lowest value
I want to select the last 10 inserts of a table and among these 10, return the lowest value. It is possible to do this in a single query? Selecting the last 10 values: SELECT id_relevo FROM relevo…
-
1
votes1
answer944
viewsShow Alert on select
I have the following code $query = mysql_query("SELECT id, nome, situacao FROM clientes ORDER BY nome") or print mysql_error() <select class="js-example-basic-single form-control" id="cliente"…
-
1
votes2
answers715
viewsWith limit Select output on Oracle
I’m making a bank select and it’s returning me 15 lines. I used ROWNUM to pick up the first 8 lines, only I want to do another select and pick up from line 9 to 15. SELECT * FROM (SELECT DISTINCT…
-
1
votes0
answers376
viewsCustomize select and understand the CSS effect
see this example I’m doing about customization of a select and an input http://codepen.io/anon/pen/peVNoq Note the input effect, click on the text box and you will see that the bottom edge has a…
-
1
votes1
answer98
viewsGroup_concat in JPQL
I created the following`query: SELECT o.codigoChamado, o.codigoOrcamento, group_concat(o.conteudoOrcamento), o.observacaoOrcamento FROM Orcamentos as o group by o.codigoChamado, o.codigoOrcamento,…
-
1
votes1
answer171
viewsHow to keep option after refresh - Asp.net
I have a select, some options and a jquery code that in select change, updates the screen with the data of the chosen option. The question is, how do I maintain the option after window.Location?…
-
1
votes1
answer41
viewsHow to pass SELECT DB Pervasive parameter
I’m having to work with Pervasive database, so I’m having trouble passing a parameter to perform a SELECT I’ve tried using: DBCmd.Parameters.Add("@inicio", PsqlDbType.VarChar).Value = date_inicio;…
-
1
votes0
answers175
viewsInsert Sequential Number into column C#
I have this table called Articlebarcode: In the column Code I need to insert a sequential number, that is, I have to read the maximum number that is there and insert the next one that is available !…
-
1
votes2
answers566
viewsSelect with re occurrences of a period record
I need to know if a record occurred again in a 7-day period. For this, I count with a table that saves the records and the occurrence date. For example: Registro: x | Data: 13/03/2017 Registro: y |…
-
1
votes2
answers656
viewsMysql query with PHP
I’m making an appointment at Mysql to return the quantity of orders that were not delivered. To see what was delivered I do: $result = mysql_query("SELECT operacional FROM `pedidos` WHERE `status` =…
-
1
votes1
answer72
viewsSELECT in auto-relational table
I have a table funcionario, with attributes: ID(PK) and IDCHEFE (FK from the table itself). Each employee(a) has one idchefe which refers to another official (who is his boss(a)). How to make a…
-
1
votes1
answer79
viewsHow can I merge the rest of the data with the first query in SQL
Personal I have a query in SQL that returns the values not duplicated column: Nº Tel, and that has the Status equal to TEMPORARY MALFUNCTION SELECT DISTINCT [Nº Tel] FROM [export$] WHERE [Status] =…
-
1
votes1
answer426
viewsRelationship between tables in SELECT - SQL SERVER
I’m having a question on how to add a relationship between tables. Example: I am using this command to get the data. However, it returns me with the ID’s of the other tables. I would like to return…
-
1
votes2
answers3778
viewsReturn the shortest date within Select
I have the following table: CREATE TABLE [dbo].[Crm_man]( [id] [int] IDENTITY(1,1) NOT NULL, [nCRM] [int] NULL, [cliente_CRM] [int] NULL, [item_CRM] [int] NULL, [qnt_CRM] [int] NULL, [descri_CRM]…
-
1
votes1
answer177
viewsSQL query returning one of the empty columns, different from the database
I’m doing an SQL query, in Oracle database, but one of the fields returns the empty value, different from the table in the database. I have tried to create, and rebuild the indexes, but the problem…
-
1
votes2
answers368
viewsCustomers who bought in one year but not another
I need to make a select that brings me which customers bought in 2016 and did not buy in 2017 and vice versa. This is my select: SELECT tc.`cod-emitente` AS CODIGO, tc.`nome-emit` AS CLIENTE,…
-
1
votes1
answer119
viewsList each user’s last message
Does anyone know how I could list each user’s last message? I was able to do that, but it lists the last message from just one user, and I wanted it to list everyone who sent a message to the user…
-
1
votes1
answer1994
viewsHow to identify a Job being executed?
Hello.. I created a Job in ORACLE, where it runs a PROCEDURE, but I wanted to perform a SELECT, where I returned the status of this Job. Because I will use this information to return a reply to the…
-
1
votes1
answer26
viewsReturn non-repeated lines in a Select
I am using the following select on oracle select DISTINCT delivery, dt_coletado from table1 and is returned to the following line DELIVERY DT_COLETADO 8816619995 2019-05-17 00:51:04 8816619995…
-
1
votes3
answers3142
viewsSelect Sum in table with PHP/Mysql
I have a table with the following fields: date, time and quantity. And I need to make a select sum of it. To better understand, I have a form where I insert a date, after I insert, I will make a…
-
1
votes1
answer361
viewsHow do I manipulate data from a select created from jquery
I am trying to take the values of a select that I entered through a jquery, and as the value it adds elements within a div also created by that same jquery. The problem is that I’m not getting these…
-
1
votes1
answer251
viewsHow to search for relevance in Mysql (prioritize whole word)
I have a recipes site in PHP and Mysql. The consultation is: SELECT receita FROM receitas WHERE receita LIKE '%mac%' When I search for "mac", it brings "macaroni" and "big mac". I wanted the result…
-
1
votes1
answer44
viewsDoubt in Select
I have mysql database with some registered information and I need to search through a select Championship and Modalities that a person has no link, but I have tried several ways and I could not…
-
1
votes2
answers235
viewsHow to do a search in MYSQL considering plural and singular
I have a recipes site with a simple search system. But there are recipes that are plural and recipes in singular, for example: chocolate biscuit and chocolate biscuit When someone looks for a…
-
1
votes1
answer28
viewsDoubt regarding the IN in Oracle
I’m putting together a query and bumped into a question. My query is like this: SELECT BASI_030.NIVEL_ESTRUTURA NIVEL, BASI_030.REFERENCIA GRUPO, BASI_030.DESCR_REFERENCIA, BASI_030.CONTA_ESTOQUE,…
-
1
votes1
answer37
viewsDoubt Select in Mysql
I have two city tables and people City has the columns Id/idPrefeito/idVice/nome And people Id/nome... Idmayor and Vice are Foreign Key’s people.id How do I carry in the same select the name of the…
-
1
votes1
answer134
viewsHow to return driver names in SQL table?
I have the following tables below, and I would like to return only the name of the pilots who never participated in a race in a Brazilian circuit in the country brasil. Table structure: PAIS (id,…
-
1
votes0
answers69
viewsHow to sum up an Oracle select case
I am trying to make a sum in a select case, but apparently it is not valid, the following error appears " ORA-01858: a non-numeric Character was found Where a Numeric was expected". when I remove…
-
1
votes1
answer244
viewsLaravel 5.4 - Display all phones of each result
I have the table convenios and telefones, each convenio has one or more telefones and a screen where are listed all convenios, I need you to come along with all the phones related to each meeting. I…
-
1
votes1
answer27
viewsHow do I select between two dates and bring in the query the value 0 on the dates that do not exist?
Example select data, valor from tabela WHERE data BETWEEN '2020-01-01' AND '2020-01-10'. I need that when there is no day 5, for example, the query return me the 10 dates and on day 5 the value is…
-
1
votes0
answers14
viewsORDER BY between two datetime columns
I have two datetime columns: data1 and data2. I need to sort by the shortest date between the two columns. If data2 is not zero, displays data2 line; If data2 is zero, displays data1 line; How do I…
-
1
votes1
answer42
viewsHow to make MYSQL SELECT "create" the days you don’t have in the table
I’m doing a MYSQL query that returns a download report a day, but in a few days it has no download. For example: ID|data 1 |2020-05-20 2 |2020-05-21 3 |2020-05-23 In this case, there was no download…
-
1
votes0
answers316
viewsHelp to optimize an index in mysql
I own a site of relationships and for years I try to optimize this query. Almost every day the site hangs because of it. Structure of the user table CREATE TABLE `usuarios` ( `id` bigint(20) NOT…
-
1
votes2
answers150
viewsQuery with JOIN in 3 tables
I have the following tables: livroautor id idautor idlivro ------ ------- --------- 1 1 (NULL) 2 2 2 3 3 3 4 4 4 5 5 5 6 6 (NULL) 7 7 5 8 8 2 9 9 2 10 10 (NULL) book id titulo resumo isbn paginas…
-
1
votes3
answers789
viewsProblem sorting sql with orderby Date in postgresql
I have the following query that results in the union of the total sum of an account and the installments select sum(total) as total, datavencimento from ( select sum (con_valoraserpago) as total,…
-
1
votes2
answers763
viewsselect multiple columns group by 1 column
I have a table with 300 thousand records and within it there are several different fields, I would like to take the line that contains the largest OUTGOING DATE calculated for each CPF_1 what I…
-
1
votes3
answers241
viewsIdentifying SQL brothers
I built this link as an example of where I want to get http://sqlfiddle.com/#! 9/72f4b5/4 I have the student table. I have the table with the sibling ids My problem is, I need to make a select so…
-
1
votes1
answer23
viewsQuery with two summation results from a condition
I need to perform a query in a table of sold items where there is a Tipoitem field that says if the item is Product(1) or Service(2), I would like it to bring me two SUM’s from one of the Ocisubtot…
-
1
votes1
answer51
viewsphpMyAdmim Database Connection Error (New Code) Nothing is solving
Look, I don’t know exactly where to start but, anyway... I have the page posted below, and I’ve checked some with errors in the database and entering data in it. The code was made in case there is…
-
1
votes3
answers80
viewsDisplay only one message at the end of an operation within a WHILE
I have a situation. I do a search in a table and from the returned data, insert in a new table and update the current one. Ex: $busca = $link->prepare("SELECT valor FROM tabela1 WHERE funcionario…