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
-
3
votes1
answer1316
viewsHow to Make Select Self Relationship N:N
I am unable to perform an SQL query with relationship N:N. I have a table of users and another with self relationship user_has_usuario, who will be registered responsible and students (from a…
-
3
votes1
answer64
viewsHelp! How this select works
Help me understand how this works please. I happen to be starting the studies in SQL and hackerhank has an exercise that needed this code: SELECT DISTINCT CITY FROM STATION WHERE…
-
3
votes3
answers83
viewsSelect different value from "X" name
How do I select in a given column only the different ratings of "X"? I created select below: SELECT top 1000* FROM [tabela_clientes] WITH (NOLOCK) WHERE STATUS= 'pendente' and status_2= 'pagamento'…
-
3
votes1
answer659
views -
3
votes4
answers949
viewsChange select element value (Ajax + php) with innerHTML
Hello, I’m doing the famous combo of state carries city. Everything is working perfectly, as I will debug in my script, until the moment that must change the value of select (options returned from…
-
3
votes2
answers746
viewsCount how many fields are empty on a MYSQL line
I have a registration table with 53 columns (address, phone, etc). I wanted to set up a consultation that would bring me how many of these columns are empty or NULL, how can I do that?
-
3
votes3
answers422
viewsClone <select> jquery / javascript
Guys, I’m a beginner and I’m having a hard time running this code I used from another topic right here (Add and Remove Fields with Javascript). Here it did not run, but on my localhost it even…
-
3
votes3
answers924
viewsCan you start a Select (SQL) in the middle of the data table?
Friends, is there any way inside the SQL language (and using mysql BD) where I can start a Select in the middle of a table? For example, I have 500 addresses in the table. I do a search of…
-
3
votes3
answers81
viewsSimultaneous consultation and amendment
Considering a table similar to this: Tabela : [Frutas] ╔════════╦═════════╦═════════╗ ║ Fruta ║ Cor ║ Mordida ║ ╠════════╬═════════╬═════════╣ ║ Maçã ║ Verde ║ Não ║ ╠════════╬═════════╬═════════╣ ║…
-
3
votes3
answers68
viewsProblem in select order
I fed this graph But I have a problem with his selection <?php $sql_2_vis = mysqli_query($config, "SELECT data, uniques, pageviews FROM tb_visitas ORDER BY id DESC LIMIT 7") or…
-
3
votes3
answers1854
viewsSQL query to know the sales of a period (year), dividing by month and showing the total of each month and year
I work as a technical support in an automation system, a customer asked if there was a report in the system that showed the total sales of 2018 divided by month and showing the total of each month…
-
3
votes2
answers358
viewsHow can I select unique data in SQL?
Hello would you like to know how can I select unique data in SQL? I have an Excel spreadsheet that has the daods that I need to extract information by applying the following filter in sql: GSM which…
-
3
votes1
answer653
viewsIs it possible to make a direct SPLIT in a QUERY (SELECT) in SQL SERVER 2012?
I have the following table below and I need to divide the "Full Name" column into columns in the same SELECT where each column should be filled according to its level. Ex: The Full Name column…
-
3
votes1
answer57
viewsHow to do a column search scan with counter bar character
I am trying to perform a query in a table similar to the one below through a field diretorio. +----------+---------------+----------------------------------------+ |id_imagem | data_upload |…
-
3
votes1
answer36
viewsQuery to find duplicate by DATETIME (MYSQL)
Good morning to all. I need help to better understand how to apply a query that I’m developing. I would need to formulate a SELECT to seek certain records within a period involved (DATETIME). On DB:…
-
2
votes3
answers2007
viewsSelect records from a table where the record of a related table is a specific value
I have a table of technical calls and a table of appointments. Each 'CALL' has several 'CALLS' and it is in the calls that is the field that defines the status of the call (Open, Closed, In…
mysql codeigniter select relational-model active-recordasked 10 years, 8 months ago EdnaldoNeimeg 109 -
2
votes1
answer497
views -
2
votes1
answer1379
viewsSelect a Mysql table inside a PHP file without refresh
Select Mysql database data inside a PHP file without refresh. Example: <?php // Essa select abaixo tem que buscar a cada 5 segundos sem atualizar a página $selecionaTabela = mysql_query("SELECT *…
-
2
votes1
answer1143
viewsMake an INNER JOIN using IF
I am doing an INNER JOIN of the Combo Table with the Product Combo Table as shown below... SELECT C.SchoolID, C.ComboID, P.Active, P.Name, P.ProductID FROM sales.Combo AS C INNER JOIN commons.Stock…
-
2
votes1
answer142
viewsList grouped and filtered data
I’m performing a query in PUBS, the database that is used in MSDN tutorials for SQL Server, and I can’t find a way to do it. The two tables I use are the Publishers and the Titles who have the…
-
2
votes1
answer90
viewsDoubt, query does not work exactly as I want... PHP
I have a table in the database called emails, with the following fields: id subject body e status (0, para não enviado, ou 1, para enviado). I was making a query to recover only the lines that have…
-
2
votes1
answer179
viewsSELECT display difference between browsers
I have the following code HTML that marks a SELECT: <select name="filtro"> <option value="">Mais visualizados</option> <option value="">Menos visualizados</option>…
-
2
votes2
answers3503
viewsSelect to subtract current value from previous and return column with result
I have two tables: Samples and Values, which have columns as follows: TABLE Samples Amostra_id Data Operador_Id Carta_Id TABLE Values Amostra_Id Valor As you can see, the Values table relates to the…
-
2
votes2
answers519
viewsHow to replace from one server to another?
I have the table below in 2 servers and I need server 1 to send all this information to server 2 ie fields id, username, iddns, dns, ipdnstipo e ipdns as it is. Table CREATE TABLE IF NOT EXISTS…
-
2
votes3
answers458
viewsSearch database table information with PHP every 10 minutes
I need to search for information from a database table every 10 minutes using PHP. Does anyone have any idea how I can do this?
-
2
votes1
answer119
viewsUnselect items when moving between listboxes
In my application I have two listboxes, one with "players available" and the other with "players climbed", as well as two buttons to move the items between them, >> and <<. My problem is…
-
2
votes1
answer823
viewsCheck if any Select output line in Mysql contains a value
I would like to know how to check in the Where clause if any of the lines has a certain number. For example: If a select returns 1 2 3 4 and in clause ask the 4 it returns the values, if return 1 2…
-
2
votes3
answers55
views -
2
votes2
answers2053
viewsList in each position, the employees who most had change of position
Good evening, everyone. I have a little problem that I’ve been trying to solve for a while and I came to ask here. It is as follows: I have three important entities for this solution: To make it…
-
2
votes3
answers516
viewsColumn outside the SELECT WHERE condition
I need to make a query that returns a column with the amount of orders that the customer made within the period past in the WHERE and put together another column with the total orders that the…
-
2
votes1
answer4232
viewsAndroid Sqlite: Displaying bank content in textView?
I would like to know how I do to display content from the Sqlite database in textviews. I am using the following method to display in a Customlistview: public Cursor getAllData () { String buildSQL…
-
2
votes1
answer148
viewsvalue of select in array
Good, Looking at this query: $sql = mysql_query("select A, B, C, D from table"); $row_sql = mysql_fetch_assoc($sql); I want to take the A column and put all the values in an array: $var =…
-
2
votes1
answer67
viewsMaximum and minimum payment
I have two tables, customers and payments, I want to verify from each customer which was the largest and smallest payment each made. I did this SQL, but it didn’t work, someone could help me? SELECT…
-
2
votes1
answer400
viewsAdd records with type
I have 2 tables linked by id and need to add a field in table 2 grouping through a field in table 1 -----TABELA 1----- ID_tab1 - tipo_pgto -----TABELA 2----- ID_tab2 - ID_tab1 - valor_pago I want…
-
2
votes2
answers130
viewsHow to insert 200 new records?
I need to insert new data into a table, but there are many. I did so: insert into pessoafisica (coluna1, coluna2, coluna 30) select (dado1 dado2 dado30) But there are many, can not do 1 by 1.…
-
2
votes1
answer1039
viewsHow to make a select starting with a certain line
How do I get one Select starting for example from the second row of my table? I know that using the ASC limit 1,1 I can pick the second line, but how to start from it?…
-
2
votes0
answers299
viewsSelect from a table within a cell of another table
In the SQL SERVER 2012 it is possible to construct a table that in one of its columns contains the result of another table? The master key would be the reference.…
-
2
votes2
answers346
viewsSearch in mysql database with multi-level php
I’m trying to perform the following query in the database, through an html form, only in php I’m only able to fetch all the data from my table. In case the user would choose the type of filter and a…
-
2
votes1
answer646
viewsSelect of cities and states on the site
I’m riding a website, and on the home page I created a select for states and cities, the problem is that the home page of the website is catching up too. Does anyone know how I can do this select…
-
2
votes1
answer7457
viewsHow to make a SELECT with Entity Framework?
I’m developing a kind of a C#QUIZ, and I’ve managed to do the INSERT part of the questions and answers in the bank, but I’m having difficulty bringing the question and the answers from the bank to…
-
2
votes3
answers833
viewsSelect works on the localhost but does not work on the server
The select was working normally on wamp, but when uploading the site to the server the information of some of the sites simply stopped coming. The only part where the selectis working is the login…
-
2
votes1
answer624
views -
2
votes1
answer63
viewsHow I select several values from the same table
How do I select the values 1, 2, 3, 4 and 5 of the same table without doing that lot of SELECT ? <?php $rateone = 1; $ratetwo = 2; $ratethree = 3; $ratefour = 4; $ratefive = 5; $query = "SELECT…
-
2
votes1
answer415
views -
2
votes1
answer1233
viewsLeft Outer Join does not bring Null values
I have two tables: formulario_campo ( cod_campo, descricao, cod_formulario ) Filled with the following values - input_nome, Nome, 1 - input_sexo, Sexo, 1 The second table: —…
-
2
votes1
answer236
views"Fine tuning" in SELECT for a ranking system
I’m having difficulties using Mysql. I’ve been asking here already, and I’ve done several tests and progress in the elaboration of a select for a ranking. I have a "player" table that guards among…
-
2
votes1
answer375
viewsUpdate in a table with values from another
How to update the values of a table, using values taken from another table: UPDATE produto -- atualizar a tabela produto SET produto.quant = SUM(entrada.quant) -- produto.quant será igual a soma da…
-
2
votes3
answers3385
views2 COUNT within a SELECT with LEFT JOIN
I have two tables: users: id | nome | email shipments: id | id_envia | id_recebe Every time a user sends a card (which goes by email) to another user, mark this table, and every time they receive…
-
2
votes2
answers1181
viewsSelect with duplicate record
I have a question that may be trivial for most, but that I stuck here, I seek to research a lot before posting, but I will need a help. I am setting up a select to bring me the closure of the…
-
2
votes2
answers114
viewsReturn vehicles that have all parts in a given table
I have the following question, in my database I have the following tables: | veiculo | | idVeiculo | placa | | peca | | idPeca | nomePeca | | relVeiPec | | idVeiculo | idPeca | | pecaObrig | |…