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
votes1
answer123
viewsAjax / Jquery - Select / mark an option disabled automatically
Fala galera! The following is, I have a dynamic page where the elements of the selects are loaded via Ajax according to the elements previously selected in other selects, type, for example, when…
-
1
votes2
answers71
viewsProblems in an SQL query
Hello, in the following query, an error is shown in the: select fto.id_taxon, fto.cd_sexo as fto_cd_sexo, fto.cd_idade as fto_idade, x.ftv_cd_sexo, x.ftv_cd_idade, x.id_fv from tb_foto_ocorrencia…
-
1
votes0
answers127
viewsPopular a select with php result using jQuery and cakephp
Hello, I’m trying to popular a select with the options that are returned, according to what the user selects in a particular select. The problem is that I’m a layman with jquery and I don’t know if…
-
1
votes2
answers888
viewsHow to compare 2 cells in different columns - SQL
I need to make a SELECT searching some data with the condition that only if the value of a given cellis different from another cell. Ex: +-----------+------+------+ | Descricao | Val1 | Val2 |…
-
1
votes1
answer599
viewsValue tuple using mysql Procedure
I have a form where there are two fields, a service and another value, for each service the user has to put a value, after the user chooses, I check in the bank how many lines will return me with…
-
1
votes2
answers1660
viewsSelect Where in LINQ
How to convert code select below in LINQ? select * from producao where id not in (select idProducao from bpi)
-
1
votes1
answer26
viewsHow to create relationships between different data to perform an action?
This statement returns me the state acronym: SC $("#billing\\:city").val(dados.uf); I have a select so I can’t change: <select id="billing:region_id" name="billing[region_id]"> <option…
-
1
votes1
answer82
viewsSearch records for a given day of the week
Staff I have the following select set temp = Conn.Execute("SELECT * FROM tbl_estacionamento ORDER by id asc") I have a table called date where I record the day of registration of information, I…
-
1
votes1
answer4141
viewsChecking that the value of the database column contains only numbers in select
I need to find out if the value of a given column of the database contains only numbers in the select itself, because if it is numerical, I need to display the value of another column. I use an…
-
1
votes2
answers44
viewsMake top 10 by checking 3 tables
I have 3 tables: sponsors id | id_patrocinador | id_usuario quotas id | id_user | quantidade users id | nome | login What I need to do is a TOP 10 where I list 10 users who have more sponsored with…
-
1
votes2
answers212
viewsRead column values - C#
I need to read the values of a column called Code_article and place them, only when the column is still empty, I execute and immediately gives the error: The object reference was not defined as an…
-
1
votes4
answers1903
viewsHow to join two lines in SELECT?
I’m having a problem joining 2 lines. I did a lot of research, but I couldn’t find anything that could solve my case. In the query below, there are two SELECT, which return two lines for each…
-
1
votes1
answer918
viewsMysql query - Take the next value greater than 0
Example, I need the query to return me these circulated values. The previous result was 0 (zero). The current one is not. I need to take the current one. And list…
-
1
votes1
answer78
viewsChange email destination by clicking a select option on a form
Well, I have a form and need when selecting a select option to change: 1 line - action 2 line - value 3 line - value 15 line - Change where this is written environmentOrca2 to for example…
-
1
votes2
answers71
viewsSelect from all companies that have catalogues
I’m having a problem at a select in two tables that are returning the value twice. I have the table businesses and table catalogues which are linked by company id. and catalogues.id_company. When I…
-
1
votes0
answers73
viewsHow to show decimal places only when they exist?
How could I make in my select the numbers appear without decimal place when they are 00 and appear decimal places when they are non-zero. Example: I have 5 numbers returning like this: 16.00 ; 10.00…
-
1
votes1
answer1636
viewsHow to make a query per day, week, month period in Mysql
How do I query for period, day, week, month in Mysql? for example I would like to display data filtered by periods example display data yesterday, last week, two weeks, three weeks, a month ago and…
-
1
votes2
answers382
viewsFilter SQL query
I own a field called emailMSG0 within a table in the database. This field contains various information. Is there any possibility in SQL I filter what I want to get inside this field emailMSG0 ?…
-
1
votes3
answers1291
viewsFill select javascript / jquery field
Hello, I need to fill a select field with the return of this function, in this example, the RES variable returns: <option value="">setor 1</option> exactly that, I need it to become one…
-
1
votes2
answers304
viewsselect field when opening javascript / jquery page
Hi, I had already received a great help when I needed a select field to be filled automatically, in this post here: Fill select javascript / jquery field is working perfectly mind, but now I need…
-
1
votes1
answer107
viewsGet all selected data with javascript in multiple select field
I’ll describe what I’m trying to do: There are sectors, and in each sector there are several employees, and I need that when selecting a sector in a field select, the next field select (that will…
-
1
votes3
answers76
viewsHow to do sub-consultation with Pdo
I would like to perform a sub-query within that query: $ranking = $pdo->query("SELECT * FROM usuarios_emblemas GROUP BY usuario ORDER BY count(usuario) DESC LIMIT 3"); It would be to block the…
-
1
votes1
answer349
viewsReturn lower value of a SUM?
I have a SELECT with SUM and would like to understand how I do to return me the lowest sum of all value per supplier. SELECT distinct fornecedor, cliente, SUM(valor*qtd) AS TOTAL FROM orcamentos…
-
1
votes1
answer61
viewsHow to use two scripts in a single select (onechange)
I have a question: I have two scripts, one to change the image and the other of the respective select, and the other to make the calculation between them. I would like to use both for the same…
-
1
votes2
answers54
viewsMysql - Multi Selects in a query
I need to get all columns of a table and more a custom column in the same query, I tried this way: SELECT (SELECT * FROM clans WHERE ID=1), (SELECT COUNT(*) FROM contas WHERE Clan=1) AS Membros; You…
-
1
votes2
answers306
viewsIF condition between Mysql PHP tables
Opa, I have two tables: forma_pagamento and forma_pagamento_selecionada. I have a while where should be listed all forms of payment, so in this while should have a condition IFwhere will return me a…
-
1
votes1
answer1533
viewsSplit column into multiple rows (split)
I have a table cidade_bairro with several cities and neighborhoods. I want to transfer this data to a new table, but in several lines instead of being in one. EX: Cidade Bairros<br> SP |…
-
1
votes2
answers47
viewsWhen I do the UPDATE it saves in the database correctly, but when I update the page the data disappears from the database
I am trying to recover the data from a table inside an input where the user can be updated and save in the same table through UPDATE. I managed to do the UPDATE, but edit the data by input and send,…
-
1
votes2
answers183
viewsLIKE does not work together with BETWEEN
Something wrong with this query? It is showing all the data without any filtering. But when I take the LIKEs It works or if I take the BETWEEN and leave the LIKEs it works. One works without the…
-
1
votes1
answer271
viewsSelect with MYSQL when it exists in one table and not in the other
I have two tables: QUIZ QUIZ_GERAL I would need to list data from both tables when: The logged in user ID is equal to the IDCONTA field OR When there is a row in the QUIZ table and there is no row…
-
1
votes1
answer212
viewsPHP/Mysql Select total balance of 1 client in the table
My client JOSÉ appears 4 times in this table, and I wanted to take the total of his balance. How do I do this? tabela "clientes" ID NOME SALDO 1 josé 10 1 josé 20 1 josé 30 4 maria 50 5 marta 60 1…
-
1
votes1
answer46
viewsSQL query using order by filtering by log
I have the table: | cod | hora | produto | Amostra | Min | Max | |-----|-------|---------|---------|-----|-----| | 1 | 08:00 | 96722 | 1 | 100 | 200 | | 2 | 08:23 | 96721 | 1 | 90 | 90 | | 3 | 08:50…
-
1
votes1
answer812
viewsHow to use CASE WHEN in an IN statement?
In a query I am gathering data on representatives, customers and sellers. Some representatives have sellers, who in turn have customers. These cases are exceptional as clients are directly linked to…
-
1
votes1
answer158
viewsHow to Make two or more Select categorized in the same query
I need to take all words with 'A' and play 'Palavrascoma' and all words with 'B' and play Palavrascomb, and can have C, D E... The closest so far was that, but only with the first. SELECT w1.wd as…
-
1
votes3
answers196
viewsQuery listing the dates
Good night, How Query can get the following action in Postgresql: List the dates that fell on Sunday of the last 6 months based on the current date, regardless of the data in the database. NOTE: The…
-
1
votes1
answer329
viewsHow could I add an ICONE inside a SELECT in HAML
Hello, I would like to add icons (from source, like bootstrap for example) inside a select field in HAML, at first I am doing so, would that be possible? I thought about using the bootstrap…
-
1
votes1
answer763
viewsHow to return the records between two values with the SQL Server Database?
Example of my table: My question is this... On my featured news page have to appear the 2 latest news and on the secondary news page have to appear the 2 other news in sequence. Example: in the…
-
1
votes0
answers210
viewsHow to dynamically initialize a Select2 in Angularjs
Hello guys I am using the plugin of Select2 in my project. I need to create several selects2 dynamically, by angular. I have an object array (with id, name) and accurate from an event, in a function…
-
1
votes1
answer70
viewsCan you improve these 12 selects where only one parameter varies?
I have an online table with about 3 thousand records. I make twelve selects to list the results per month, ex: select count(campo) from tabela where extract(year from data) = 2016 and extract(month…
-
1
votes2
answers1338
viewsT SQL Merge Two Lines in One
I have a common id (103307) and would like to join two lines in one. From image 1 and leave as image 2. It is possible?…
-
1
votes4
answers1103
viewsSELECT with two results
Table: PEOPLE id - nome 1 - BEATRIZ 2 - MARIA 3 - CARLOS 4 - MARIA 5 - JÉSSICA 6 - HENRIQUE How do I make a SELECT that gives me as a result a list of the names ordered by ID descendente, however, a…
-
1
votes2
answers1807
viewsINNER JOIN with equal fields in a table - Error: #1066 - Not Unique table/alias: 'tb_usuario'
I have 3 tables as follows: At tb_usuario, I have two types of users (buyer, seller) in an ENUM field to differentiate the type of user. In the shopping cart I have the user Ids, product and…
-
1
votes1
answer143
viewsSelect with subquery
I have the following select: SELECT id_usuario, SUM(CASE p.tp_honorario WHEN 'Mensal' THEN (h.vl_honorario * 12) ELSE h.vl_honorario END) as valor FROM empresa_honorario as h INNER JOIN honorario as…
-
1
votes3
answers922
viewsHow to create a table (empty) from a selection of other tables?
EXAMPLE: I have two tables : Tabela1 : two-column id_product, product name; table 2 : three-column id_brand, id_product, tag I would like to create a Tabela3 from a selection of the Tabela1 and…
-
1
votes2
answers1722
viewsSQL query with PHP array
I have an array that will be variable, e.g.: $ref = array('123', '654', '555'). I wanted to make an SQL query to bring the information of these references, something like: SELECT * FROM tabela_itens…
-
1
votes1
answer66
viewsdoubts with select and angular Js
I’m using the selectize and Angularjs, my selectize is configured like this: in the controller //configurando o select mrdicamento $scope.selectize_medicamento = { plugins: { 'remove_button': {…
-
1
votes1
answer37
viewsHelp with SELECT returns
The SELECT below when run directly in Phpmyadmin, returns all the results I want, but when I use in PHP function it comes empty: $user = $_SESSION["usuario"]["id"]; $sel =…
-
1
votes2
answers1174
viewsHow to do more than one select in the same query?
How can I do more than one select in the same query? I tried it this way (using UNION), but it didn’t work: DATABASE Table: cameras_lines id_camera_linha | nome_linha_camera Table: manufacturers…
-
1
votes1
answer228
viewsDisplay datepicker as selected
Good afternoon, I’m racking my brain to display the date as the user selects. Example: select 01 - "From/To" dates appear select 02 - Only "Until" select 03 - Only "From" select 04 - No dates shown…
-
1
votes1
answer1020
viewsGroup sum by month and year
I have a simple table in a FIREBIRD database: idCliente: integer dataPagamento: date valor: numeric How to make a select that adds up all amounts payable, grouping by month and year? kind of: select…