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
-
2
votes1
answer71
viewsSELECT of Header and Items of an XML
Hello, How can I select one XML with header and items? I have it: DECLARE @XML XML = CONVERT(XML,' <ROOT v="2.15.0"> <LOTEANIH APP="00B1" LOTE="1"> <LOTEANIM ANIMAL="10" />…
-
2
votes1
answer122
viewsHow to check if there is a number in several fields of a table
I have a table in a Sqlserver database that simulates a bingo card. In total there are 25 fields that represent the card: n1, n2, n3, ..., n25 Let’s say I drew the numbers 5, 28 and 67, as I do a…
-
2
votes1
answer260
viewsC# - Run Oracle Procedure and then select from the created session table
Hello, I’m trying to do the following. I have a database that performs a select and inserts the data into a table that only exists in that session. I need to run this trial and then refer to the…
-
2
votes1
answer91
viewsSQL query where the last 2 digits of WHERE should be ignored
I’ll try to get to the point. I got the following SELECT: SELECT * FROM "Inverter" WHERE "InstallationUUID" = '0D013C023900-15-0B4B00' AND "CreatedTime_Key" > 20170718000000 AND "CreatedTime_Key"…
-
2
votes1
answer59
viewsSelect by schedule time
Good afternoon, Folks! I’m building a TV grid app. There is a table in the database that contains information from (Program name, description and time). In my application, the system sorts this…
-
2
votes1
answer473
viewsHow to count the number of empty columns in MYSQL
I have a MYSQL client registration database. I need to make a query to know the amount of blank columns each record has. For example, in total I have 15 columns (name, email, address, etc) and "So"…
-
2
votes0
answers69
viewsDoubt mysql SELECT
Guys I’m having a question, follow the SELECT down below: SELECT o.matricula, v.cd_operador, o.hora, c.nm_nome, COALESCE(SUM(o.quantidade), 0) AS sacolax, v.sas03 AS sas03,…
-
2
votes2
answers109
viewsCONSULT DATA FROM A FOREIGN KEY TABLE
I have 3 tables in a database, one houses customer data, other products and one sales, containing foreign table id key products and customers. I need to make a query that shows the purchases made by…
-
1
votes6
answers708
viewsHow to count the number of clients that returned from one year to the next through SQL?
I have a table Serviços(Nro_Serv, Data, Cliente, Valor) and would like to get customers who did service with me in a year X (ex: 2011) and who also did in a year Y (ex: 2012). I tried to use…
-
1
votes1
answer1533
viewsList sub-query table with main query
SGDB: Mysql. PROBLEM: I need to somehow relate the subquery (being table and highlighted field Funcionario.codZona1) with the table "Zone", which is in the main query. Is there any way? Table…
-
1
votes1
answer845
viewsSelect in SQL Server with Intel
I wonder if it is possible to select in Sql Server a table that does not have an index column, but in this select display a sequential index column in ascending order. Ex. Table: Lettering Coluna D…
-
1
votes1
answer163
viewsHow to do this SELECT (SQL Server 2008)?
to be quite honest I don’t even know how to start my question. So I’ll first put the information I have. I have the following structure in my database. And I need to make a SELECT that returns to me…
-
1
votes2
answers14029
viewsMysql - Create temporary table according to dynamic SELECT
Is there any way to create a temporary table according to a select with columns created dynamically, as shown in the examples below? ex: SELECT idCentroCusto, 'Dez/14', 'Jan/15', 'Fev/15', 'Mar/15',…
-
1
votes1
answer221
viewsC# and mysql paging
I have a form and a datagrid, in this form I am using a timer to do a search in mysql that fills the datagrid datasouce, so far everything right. Now I need to limit the amount of research. Ex:…
-
1
votes1
answer1607
viewsTrigger for a Select
I would like to know if it is possible to execute a Trigger when a SELECT is performed in a given table, for example: CREATE TABLE IF NOT EXISTS "Conversa" ( "idConversa" SERIAL NOT NULL,…
-
1
votes1
answer1126
viewsPrevious registry Mysql
Hello I am trying to see the previous record in relation to the current record. I am using the following Cód. SELECT * FROM Tabela WHERE compoid <"Contraband" ORDER BY compoid DESC LIMIT 1; But…
-
1
votes1
answer177
viewsSQL: Can I have clauses in Groupby that don’t appear in Select?
I know I can’t have clauses in select that don’t appear in Group By. But is it possible otherwise? For example: Select B From Table Group By A,B
-
1
votes2
answers372
viewsPHP in_array() function
I’m developing a system that takes the ID’s from categories that are stored in the database, separated by ,, am using explode, turning them into a arrayand soon after I’m using the function…
-
1
votes3
answers776
viewsPDO paging - Problems with prepare(); select();
Hello, I’m having trouble printing table data. Updating: I inserted the following lines in the file php connection.: public function select(){ $sth = $this->prepare("SELECT id_prato, titulo,…
-
1
votes3
answers789
viewsException in sql query
How do I view my Mysql database items in php, so that you select all items except one item. Ex: I have several records... item 1 | id01 item 2 | id02 item 3 | id03 item 4 | id04 item 5 | id05 item 6…
-
1
votes1
answer136
viewsDisplaying null results for mysql related tables
I need to create a relational query that returns records containing data from both the PERMISSAO table and the USUARIOS table. ALL PERMISSIONS records must be displayed. When there are no USER…
-
1
votes1
answer962
viewsQuery SQL returning duplicate records
I have two tables (adwords_performance and analytics_transaction) and I need to make a SELECT adding up the columns adwords_performance.clicks, adwords_performance.impressions and…
-
1
votes3
answers565
viewsRepeat LEFT JOIN with other parameters in the same query
I have 2 tables: FATHER: id nome SON: id idpai sexo_filho I wanted to make a SELECT that adds up the amount of children male and female, that’s the problem, I can only do with one of the sex: SELECT…
-
1
votes1
answer5098
viewsSelect nested Mysql
I’m trying to get the most value out of the smallest of a table, the query I’m trying to execute is as follows: SELECT district FROM (SELECT district, MIN(postal_code) FROM address WHERE postal_code…
-
1
votes1
answer1176
viewsHow to make select using mask on output
I have a client table, and a command field of varchar type. Cpf is stored without mask. Ex:"00751595170" I would like to do a select that format the result by putting on the masks. "007.515.951.70"…
-
1
votes1
answer1124
views -
1
votes1
answer490
viewsError returning mysql database data
I made a normal form that returns the data in HTML. So I decided to insert images in the database and then gave a warning: "Notice: Array to string Conversion in E: sites htdocs progdesenv2 admin…
-
1
votes1
answer458
viewsInner Join table on 1 = 1 can be considered a gambiarra?
I have a table of provas and a table of alunos who have no direct relationship, I still have a table of inscrição aluno and a table of escolas, as follows in the modeling below: I need to create a…
-
1
votes0
answers215
viewsSELECT in MYSQL grouped by month, but showing all
I have the following table in MYSQL: cavalo - 2016-01-15 cachorro - 2016-01-16 gato - 2016-02-23 coelho - 2016-02-24 ovelha - 2016-03-21 tatu - 2016-03-22 I wanted to give a SELECT and show that…
-
1
votes1
answer288
viewsRun an UPDATE on Mysql only when the number of Rows is 1
How to make a UPDATE only run when the number of Rows returned is 1 in a single query with SQL syntax only using the example below? Example: SELECT count(*) AS rows FROM exemplo WHERE id_usuario =…
-
1
votes0
answers42
viewsJquery mobile filterable select ignore accent
Good, I am trying a select box taken from this example http://view.jquerymobile.com/master/demos/selectmenu-custom-filter/ works perfectly but when trying to filter the results by writing for…
-
1
votes3
answers4076
viewsSELECT with PDO and variable
How is it possible to make a SELECT in MYSQL with PDO next to this below: $buscarNoticiaTitulo = "noticias.titulo LIKE '%teste%'"; $sqlNoticias = $pdo->prepare('SELECT * FROM noticias WHERE…
-
1
votes2
answers64
viewsQuery Query 1:N
I have the following tables: Tabela: estoque id_estoque nome Tabela: atributos id_atributo id_estoque nome And for example I need to know if there are 2 name attributes X and the name Y stocked Z.…
-
1
votes1
answer92
viewsOptimization of SQL Query
I set up a series of SQL but I’m having difficulty generating something that stress less the server, I ask help from you. Follows the SQL: SELECT '2015-06-10 00:00:00' AS 'Hora', COUNT(id_contato)…
-
1
votes0
answers168
viewsHow to find out select without Where in one application
Guys I’m having a problem and I can’t identify at which point the Portable is doing a select without Where in a table with many records, someone can help me?
-
1
votes2
answers90
viewsSearch for two Mysql tables in php
I have two tables that are: Registration Dorsal(id auto_increment Primary key); Name; Team; Classification Place(id auto_increment Primary key); Dorsal (Foreign key); and the following code in PHP:…
-
1
votes2
answers67
viewsSearch only a random part within a select mysql code
The problem is this, I have the code concatenated, I need to see this code concatenated if part of it is in the table, ie when joining field 1 and field 2 with PHP, before searching in the table, a…
-
1
votes1
answer108
viewsHow to return an SQL with result?
I need to select several tables linked by the "user id" and return the data to compose a profile page, but some of these tables may be empty at first, that is, the query will not find the "user id"…
-
1
votes1
answer77
views"top" with MAX in mysql
I need to make a query that returns the 3 highest salaries of civil servants, per state. example that should return: fulano 850 RJ ciclano 800 RJ beltrano 700 RJ joao 1000 SP maria 900 SP pedro 200…
-
1
votes0
answers227
viewsMaking Mysql UPDATE in DB database according to Mysql SELECT in DB2 database
I need to update a field (office) of a table (investor) of the database (B2c) on my website. However, this UPDATE will depend on a SELECT query that is made in another database of another site (both…
-
1
votes1
answer32
viewsdisable select in cakephp
I have 2 selects, and want to make sure that when one of the select is with a different empty option, the other select enter disable. Follows my code: <script type="text/javascript"> function…
-
1
votes2
answers790
viewsSelect the country and bring the state
I have a code that’s on Codeigniter. He has the page to register a user. This page asks him to put the country and the state he lives. I needed it when selecting a country to come the corresponding…
-
1
votes1
answer89
viewsHashbytes with different value when selecting and writing with update
SELECT HASHBYTES('MD5','123') This select above returns me the following result: 0x202CB962AC59075B964B07152D234B70 But when I update the table using the same hashbytes UPDATE USUARIOSLOGADOS SET…
-
1
votes0
answers85
viewsPIVOT Help - SELECT SQL
I have a table with the data: unidade tipo valor 1 2 10,00 1 3 15,00 2 2 16,00 3 3 10,00 3 1 25,00 I need to make a select with pivot that brings me unidade tipo1 tipo2 tipo3 1 0,00 10,00 15,00 2…
-
1
votes1
answer223
viewsHow to select a larger number of records based on another SQL table
I have an IMMOBILE table ID | Tipo | endereço 1 | Casa | Rua teste 2 | Casa | Rua teste 3 | Apartamento | Rua teste And a sales chart id | ID_do imovel 1 | 1 2 | 2 I need to know based on the sales…
-
1
votes1
answer4404
viewsMysql: Pivot (p rows/ columns) columns with the result of a query dynamically
I have two sets of tables below: 1: 2: I created a query that brings the results of the two tables using Union: Select tbprojeto.projNome As Projeto, tbindp.indPNome As `Tipo(Ind/Idx)`,…
-
1
votes2
answers1980
viewsHow to group results from a row query to columns
Good afternoon, have this query SELECT tblcliente.idCliente, tblclienterespostapre.resposta FROM tblcliente INNER JOIN tblclienterespostapre ON tblclienterespostapre.idCliente = tblcliente.idCliente…
-
1
votes2
answers55
viewsReturning only one select at a time multiuser
I have several clients connected to a bunch of data. These customers make inquiries, almost at the same time, causing me headache, when 2 customers catch the same result of a select. How do I know…
-
1
votes0
answers116
viewsMysql Query in Node ignoring difference condition
I have had a peculiar problem while changing my Node.JS server to certain Mysql queries. I have the following code that works normally in Mysql Workbench: SELECT id, nome FROM `tabela` WHERE…
-
1
votes2
answers519
viewsPlaceholder does not appear after applying "padding" to input
Hello, I have a very silly and simple problem that is making me waste a P#@& time! come on.. I’m using the Bootstrap v3.3.6 CLASS="form-control" In case someone wants to make an inspection on…