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
-
0
votes1
answer160
viewsMake two queries in the same table in Mysql
I have a table in Mysql database where I will make a query. This query needs to be done as follows: For those who have a plan on the site: Allow searching by: name, category (different table),…
-
0
votes0
answers269
viewsSQL query for ASP.NET page with C#
On my client’s website, I have an SQL query that brings the result of the level of readiness of several collaborators. Only that, for now, I can only transfer to the page the result of the query in…
-
0
votes1
answer233
viewsSQL - Select with possible concatenation
I created a query that concatenates my results. It is a table with names and to which range (square) they are classified. The table is called consulta_readiness and the fields are name and squared:…
-
0
votes1
answer340
viewsHow to compare two Oracle Datetime columns
I have a column where I enter a date when the event happens (local storage), and the date when the event is sent to my system. The difference between the date of the event and the date of dispatch…
-
0
votes0
answers95
views -
0
votes1
answer44
viewsSelect using an array?
I have the following array: var arr = ['A', 'B', 'C'...]; And in my database I have the column categoria where values are saved in the following mode: 'A,B,C...', how could I make a SELECT picking…
-
0
votes1
answer544
viewsHow to optimize a select within an update?
I created a stored-Procedure which updates the Drive table balances. At first I tried to use From Movimentacao within the update of the drive, only that returned error. I fixed this problem by…
-
0
votes1
answer13
viewsHelp with ORDER BY clause by string
I have the following select command: select nome, case grau when 0 then 'QS' when 1 then 'CI' when 2 then 'CDC' when 3 then 'QM' end grau, case faixa when 0 then 'NÃO' when 1 then 'SIM' end faixa,…
-
0
votes1
answer291
viewsHow to query MYSQL in 2 columns and sort 1st results of title column and then Description column
I’m setting up a job agency website and I have a search that searches the field title and description, what the person searched, as per the query below: SELECT * FROM vagas WHERE (titulo LIKE…
-
0
votes0
answers113
viewsHow to search for similar words (spelling errors) in MYSQL
I am building a search system using Mysql and PHP, with a fomulário in the _GET method. I wanted to set up a system that if the person type wrong, the site can "correct" the word, or suggest the…
-
0
votes2
answers950
views -
0
votes3
answers90
viewsHow to do more than one select in the same query in different BD tables?
The problem is this: I have the tables: Which are foreign keys in the following table: And I need to pull all the column names "modelo_conector", "nome_genero_conector" and "tipo_de_conector" and…
-
0
votes0
answers39
viewshow to format the select option when hovering over
How do I use css to leave the selected option with a certain color when hovering over?? <select> <option>werwe</option> <-- quero deixar esse cara em laranja ao selecionar…
-
0
votes2
answers48
viewsError picking a select result
Can someone help me with this code. Makes that mistake: Warning: mysql_fetch_array() expects Parameter 1 to be Resource, Boolean Given in /var/www/xxx/teste.php on line 14 Notice: Undefined…
-
0
votes1
answer92
viewsConcatenate Lines with the same User
I have the following consultation: SELECT e.id_taxe, u.nm_user, dt_taxe, SUM(e.vl_taxe) as vl_taxe FROM taxe as e INNER JOIN user as u ON u.id_user = e.id_user WHERE id_enterprise = 86 AND (dt_taxe…
-
0
votes1
answer242
viewsQuery with array returning only first record
I have the following querys: <?php $VarMensagem = 1; $pdo = new PDO($dsn, $un, $pwd, $opt); $data = array(); $dataGeral = array(); try { $stmt = $pdo->query("SELECT * FROM mensagem WHERE…
-
0
votes1
answer45
viewsselect picking up the items that are in the current day and time
I want to take items that are less than the current date and time, but when I run select from the error message, not a Valid Month. In the database the date is set as follows, '25/09/18 10:23'.…
-
0
votes1
answer15
viewsDisplay prayed results
Good evening I’m creating a referral system, But the query result does not return users with zero indications Here is my select SELECT c.id, c.nome, funcao, area, count(p.cpf_cli) AS quantidade FROM…
-
0
votes1
answer130
viewsChange select when input is completed
If the field "PANTONE" input is filled in, the field select "LINEATURA" is automatically set to "52". In PHP or JS…
selectasked 6 years, 1 month ago Júlio Ricardo 33 -
0
votes1
answer23
viewsJoin in three tables does not show all results
SELECT * FROM produto_unidades join produto_notas on produto_notas.id = produto_unidades.produtoNota_id join produto_licitacoes on produto_licitacoes.id = produto_notas.produtoLicitacoes_id where…
-
0
votes1
answer651
viewsSelect "select" values through "GET"
I’m trying and I can’t seem to do the following: I thought to "automate" the system reporting process that I am doing, for this, when registering the PRODUCT, you also register the column id name…
-
0
votes1
answer41
viewsReturn amount of dependents per employee
I need to select the Plate, the Employee Name and the Number of Dependents of each Employee, but the result of this query is showing the amount of dependents only for the first employee, and I need…
-
0
votes0
answers142
viewsMysql - Value limit for mathematical operations
I am in doubt about the following situation: I have two values not stored in table. Valor 1: 9223372036854775806 (Onde este é o valor máximo de um tipo de dado BIGINT) Valor 2:…
-
0
votes1
answer40
viewsQuery where result equals any of the values in the list
I have a table of Duplicates that has the month reference as string,(ex: 01/2012, 05/2016 and etc) And I need to perform a query between a date range, if the field was Datetime I know it would be…
-
0
votes2
answers2541
viewsHow to make a select inside another select in mysql
I need to take the lowest value of a column to use it as a condition in where, but I don’t know how to do that. The column I need is the ordering, as below: SELECT p.pro_name, p.id, f.image as foto…
-
0
votes2
answers112
viewsSQL: Compare between 2 columns and return only 1
I have a table of clients that includes clients PF and PJ. In this table, if the client has CPF has no CNPJ, if CNPJ has no CPF. I need a query that checks which of the two columns is not null and…
-
0
votes0
answers26
viewsParameter by name in the query
I have the following appointment SELECT * FROM myTable WHERE ip = 192.168.1.2 I would like to make a query by sending parameter by name using DB::raw() $dados = DB::raw("SELECT * FROM myTable WHERE…
-
0
votes0
answers247
viewsHow to show options of a select according to the chosen date?
Good evening, I am developing a website for scheduling laboratories and I needed to make a condition that according to the date that the user choose it will query in the database all the…
-
0
votes2
answers520
viewsGive a select to return the exclusive values
I have several repeated values, the value can have status (different or different) or I can have two values with different/different status, and I need to compare them (in case I use a key), that…
-
0
votes1
answer410
viewsMysql, use SUM(total) > 10 quantity in WHERE
I have the following MYSQL query: SELECT SUM(A.val) AS totalvendas, B.cod AS codigo, B.nom AS Nome, B.reg AS regiao FROM venda AS A LEFT JOIN vendedor AS B ON A.ven = B.cod WHERE reg = "norte" GROUP…
-
0
votes3
answers1324
viewsSelect records from one record to another in sql server
I want to select from record 20 to 50 in SQL SERVER, but I’m not getting it! I’m wearing it like this: SELECT * FROM table OFFSET 20 ROWS FETCH NEXT 50 ROWS ONLY But it doesn’t work! I know you have…
-
0
votes1
answer106
viewsHow to return a Mysql query with specific characters within each cell?
If in my column there is a field in this format: 181202272, (a varchar of 10 characters), I would like to return in my query through a SELECT by Mysql in this way: 18:12:02.272 //Nos dois primeiros…
-
0
votes1
answer59
viewsHelp to display database data on the screen
I am doing an INNER JOIN between two tables of my bank. But I’m having trouble showing the organized result on the screen, could someone help me? The tables are of category and service (related to…
-
0
votes2
answers117
viewsExplode and compare value in a Select?
In my Mysql I have the following column data_id it stores values in this format 120-01-01, what a SELECT make a EXPLODE in that field and checks whether the first value of the array which in case…
-
0
votes0
answers48
viewsPHP put a carinha.jpeg symbol inside a <select> and record the selected.jpeg face in the mysql database field and display in the client
I have a table that generates 5 columns, I wanted to put inside a TD a select and inside the Select put 5 default images ( type emojis of Whats but in jpeg ) indicating the presence / status of the…
-
0
votes1
answer251
viewsTo repeat the value of a field in another field in select SQL Server
I have a table where there are the fields: Personal, Name and Personal (which indicates that she is someone else’s daughter from the table. and if she is the father, that field is null). I need to…
-
0
votes3
answers2475
viewsReturn 0 if the value does not exist in the table
I am using select to check if there is SEQ_RESUMO in the table. If there is this returning me the value of SEQ_RESUMO, ate ai ok. But when the value does not exist in the table, according to the…
-
0
votes1
answer38
viewsSELECT SQL - Join with created fields
I need to make a Join with the product of two SELECTbut I’m not getting to an understanding. I need the columns created (notificacao) in tabs the tables are compared and return me the data of the…
-
0
votes1
answer345
viewshow to manipulate an object inside an array in typescript
I use the last version of the angular, and I’m having a hard time passing a value to the field, follow details below I am pulling data from an api and sending in list to a select <option…
-
0
votes1
answer106
viewsRow results in columns ( SUM )
Good Afternoon, I have a big question in my query, I have a table with the following info: I would like the following result I need the result to be the total value of (forms of payments) per day,…
-
0
votes0
answers172
viewsAdd column to SQL considering some conditions to be valid
I’m trying to gather two pieces of information and I’m not getting it. I set up this SQL to bring me only the products that were purchased that had a discount through a contract. However this…
-
0
votes1
answer405
viewsPython - Retrieve BD information by column name
Dear, How to retrieve database information by column names and not by indexes? cursor.execute('SELECT * FROM [AutomacaoCampanhasDashboard].[dbo].[TBL_GCCP2]') row = cursor.fetchall() nome =…
-
0
votes2
answers798
viewsSum with Internet Oracle
Staff need a help, I need to create a report that shows the total quantity of each product in stock, but I can not make appear the name of the products, only the product code and the sum of the…
-
0
votes1
answer23
viewsSelect in Mysql
I have 2 tables city: id/idPreffect/idVice person: id/name The following select searches for me the name of the city and the name of the Mayor and his deputy... SELECT cidade.nome, ppref.nome as…
-
0
votes1
answer730
viewsSelect connecting 3 tables in Firebird with different Ids
Good afternoon, I need to make a select that returns to description of the product,barcode and price. The description and price are in one table (TB_ESTOQUE) and the barcode is in another…
-
0
votes2
answers550
viewsSQL Server - Select last 7 days from the last record
Guys I’m beginner in SQL and it’s complicated to solve this problem that came up.. I need a select in SQL-Server that returns: the sales of the last seven days. For example if the last day there was…
-
0
votes2
answers510
viewsHow to select data from the previous month and year?
I’m trying to search from dates in Mysql. I need to obtain the total sum of a value where the year and month are smaller than those reported in the variable: SELECT SUM(valor_pag) FROM controle…
-
0
votes2
answers150
viewsDoubt with SELECT in MYSQL database
I need an sql that, in the table below, always bring the last insert to each user. I tried with distinct but it didn’t work. So in the case below sql would bring the results of row 2 and 5. Detail…
-
0
votes0
answers37
viewsShopping cart error in array when recovering last id sqlsrv_fetch_array 11- is not a Valid ss_sqlsrv_stmt Resource in
I am mounting a shopping cart but am facing the following error I mentioned in the title. The method takes 2 parameter the $listProducts is an array as all purchase information and the $Total…
-
0
votes1
answer50
viewsError while trying to list objects that are in the database when using Foreach();
I am making this code to capture the elements of a table in my database but while executing the code foreach I get the bug and I don’t know what to do Function to fetch data: function…