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
votes2
answers363
viewsUsing & in Oracle Search
I’m having a question about using & on Oracle. See below my table. When searching for the description 'Easy Breezy Emailmkt & Eu', Oracle opens a window for passing parameter, as shown…
-
2
votes2
answers2006
views -
2
votes2
answers1684
viewsSelect with INNER JOIN, bringing fields that have NULL foreign key
I have a table items, requested items, interested (she has self relationship, is used for secretariat, sector and employee, and a table requested), in the table requested I have 3 foreign keys (one…
-
2
votes1
answer289
viewsSql Reader returning null value
I’m running a datareader, however does not return any value, already checked in the table and conditions (where) of select exist in the table. The code goes below: public void consulta() { string…
-
2
votes1
answer61
viewsPromotion Ecommerce consultation
I’m developing a platform Ecommerce, and I came across a problem to calculate the value of products, applying the discount of promotions in consultation SQL, currently the promotion rules are being…
-
2
votes3
answers18706
viewsUse of select with SUM() function
I am developing a database for a small application. My bank has 3 tables: students, disciplines and boletim_escolar, this last one I use to insert 3 individual notes. I was able to calculate the…
-
2
votes1
answer2011
viewsSelect with LIKE argument %
I’m trying to perform a select, using LIKE and defining the argument %: WHERE title LIKE '%computer%' locates all book titles with the word 'computer' anywhere in the book title. source:…
-
2
votes0
answers45
viewsAlgorithm to match department, category, and subcategory of a BD with a received string?
From a non-standard string, I sometimes receive the equivalent of department/category, sometimes equivalent to category/subcategory, sometimes equivalent to department/subcategory, sometimes…
-
2
votes2
answers71
views -
2
votes2
answers467
viewsDuplicate Select Postgresql output
I have a record that is a receipt, and in select, I want the line to come duplicated. Ex: Select * from recibos where codigo =1; Upshot: codigo|cliente|valor|emitente|data 1 Fulano 10 Ciclano…
-
2
votes2
answers1290
viewsHow to check Null in a select @Local_variable
To set a default value for a local variable, if the select that should "set" it returns NULL? For example: DECLARE @Minha_Var VARCHAR(70) SELECT @Minha_Var = Nome FROM CLIENTES WHERE Id = 10 This…
-
2
votes4
answers3710
viewsDoubt with month and year extraction in Postgresql date
I am using a select command where I take the month and year of the date as follows: extract(year from D.dt_ficha) + extract(month from D.dt_ficha) Only instead of showing up like this: 201711…
-
2
votes1
answer69
viewsHow to select columns in which years are equal in Oracle?
I have a table called Clientes, and in it I have the following columns : id_cliente nm_cliente dt_nascimento I need to select and count all customers who were born in the same year. I have tried…
-
2
votes3
answers1806
viewsSQL searching records from a Date and Time
I have the following SQL: select * from tb_valores where DATA >= '14/12/17' and HORA >= '16:34:00') I would like to bring all records from that date and time. The problem is that if I have…
-
2
votes1
answer508
viewsPass lambda statement by parameter - C# - Entity
I have a method in which I need to pass only one select per parameter: public List<TEntity> GetAll(Expression<Func<TEntity, TEntity>> Select) { var query =…
-
2
votes3
answers102
viewsTake Report with zero months
I have a query in which I take monthly deposited values it takes everything it has in the base and shows the months that were entered in the base. I would like to do different I would like to show…
-
2
votes2
answers186
viewsHow to select single data from a Join conditional?
I have 2 database tables: Servers +----------+--------------+ | Field | Type | +----------+--------------+ | id | int(11) | | ip | varchar(255) | | votes | int(11) | | port | varchar(255) | | hash |…
-
2
votes2
answers1290
viewsError: android.database.sqlite.Sqliteexception: no such column:
I added a column in the Users table, invited is an integer. I need to make a select in the table filtering this field, and I get the following error: android.database.sqlite.Sqliteexception: no such…
-
2
votes0
answers28
viewsSelect in two tables with clause WHERE?
I need to check if a particular e-mail exists in two tables, if it exists in one of the two tables the user will not be able to register, facilitating would be the code below, the column email is…
-
2
votes1
answer421
viewsSELECT Multiple Date Range in Mysql
Guys, I have a problem extracting dates on a range of trainings. What I need is the following if a training had its beginning on 01/01/2017 and its completion on 03/03/2017 raise should return in…
-
2
votes0
answers39
viewsCount records that precede the selected one in the sql server, mysql query
I have a question: How do I know how many records you have before a selected value. For example: Select * from cidades where nome= 'SAO PAULO' ORDER BY nome Assuming that the cities table has 500…
-
2
votes2
answers109
viewshow to change the page subtitle by choosing a select
Guys, it’s really simple, I have a form that can be used for various services. I need the page subtitle to change according to the choice (in a select) of the service. I’m using the following a bit…
-
2
votes2
answers502
viewsSQL with 2 of multiple conditions
I’m having trouble making a Select that meets 2 or 3 conditions of several selected, for example: Conditions: - Cidade Tal (São Paulo) - Nome Tal (João) - Sexo (Masculino) - Fumante (Não) - Carro…
-
2
votes1
answer108
viewsProblem to select a specific object within a hash
Hello! Good morning. I have the following situation: In my Ruby code, there is a flower class(attributes: code(generated by a function with auto increment), name, value and category(this at ributo…
-
2
votes1
answer393
viewsPull fixed data from . json to select in form
I don’t know what’s wrong that it’s not pulling the json data, my goal is to pull the city/neighborhood data to display through another javascript code, but I can’t get the select to display the…
-
2
votes1
answer13534
viewsProcedure Oracle return query lines
I have the following table: CREATE TABLE CARRO ( CD_CARRO INT ,DONO VARCHAR(20) ,MARCA VARCHAR2(20) ); The Inserts INSERT INTO CARRO VALUES (1,'VICENTE','FERRARI'); INSERT INTO CARRO VALUES…
-
2
votes1
answer504
viewsI need to select sequences of numbers in a field of a table column
I have a 'Text' column in my 'process' table. Text consists of a VARCHAR (220), in this text I need to identify a specific word pattern. In this case a sequence of numbers with a "-" to separate:…
-
2
votes3
answers180
viewsMysql - Create an alias by concatenating multiple fields
Is it possible to create an alias by concatenating other fields? Ex: SELECT u.nome, u.sobrenome AS nome_completo FROM usuarios u In the example, I want to concatenate u name. and u surname. and…
-
2
votes2
answers45
viewsError in SQL output
Guys, here’s the thing, I’m having to do a select in a bank, where I should look for values that exist between two dates, and that have a specific user. I made the select so: SELECT * FROM `tabela`…
-
2
votes1
answer19
viewsConverting columns into rows by concatenating the results
I have the following select : SELECT pedido, item FROM pedidos How do I get the result of it in columns and step to row concatenating with -? Example: Upshot pedido item 1 batata 1 arroz 1 feijão 1…
-
2
votes1
answer78
viewsSelect that returns JSON
Hello! I have the following PHP code: login.php <?php $msg; if (isset($_POST['login']) && isset($_POST['senha'])) { $login = str_replace(" ", "", $_POST['login']); $senha = str_replace("…
-
2
votes0
answers54
viewsmysql if - how to apply to equal records
Hello! staff I am trying to select and apply a rule only in equal records. I need all records to be listed, but in those that are equal, a specific rule is applied; For example, select all client…
-
2
votes4
answers1346
viewsSelect query by age group
I made an appointment select thus: SELECT data, sexo, idade, count(*) qtd FROM marcacao group by data, sexo, idade And return me a table similar to the table below: DATA | SEXO | IDADE | QTD…
-
2
votes1
answer372
viewsError using "greater than" in select command with case
I am trying to execute the following select command: SELECT estoque.id, produto.id, produto.descricao PRODUTO, case saida.quant when > 0 then (estoque.quant + sum(saida.quant)) else estoque.quant…
-
2
votes1
answer173
viewsSave value from a select and display
I’m developing a CRUD of a web system. In the employee registration I use two select elements to display the options, when registering work all ok, the information goes to the bank. The problem is…
-
2
votes0
answers32
viewsSpecial character query in SQL
I need to make a query in a table of emails, and I need to return only emails that have special characters. Can you help me with the script, I tried to use this code: Select * from tabela Where…
-
2
votes1
answer87
viewsTable with 2 td with select inputs showing return only in the first row
I have 1 table with 1 list of modules, and I have 2 columns that have options that can be chosen through select. The point is that the select’s only load the data in the first row of the table, the…
-
2
votes2
answers82
viewsSearch in two tables
I have a media table with the fields id_midia, nome, tipo and another table of synonyms that has the fields id_midia, sinônimo. I need to make a query where it checks the two tables if the term…
-
2
votes1
answer417
viewsPerform calculation in SQL command
I performed a command of select on my table estoque where I bring the supply model, your current amount and what is your minimum amount in stock, for that I made the query as follows: SELECT…
-
2
votes1
answer1510
viewsMerge the output of two Select’s - Postgresql commands
My need is to merge the result of two select commands so that I get everything back at once, for example in this command: SELECT codigosuprimento, suprimento, count (codigosuprimento) quantidade,…
-
2
votes1
answer105
viewsSelect columns in different tables
I am using Laravel 5.3 and would like to use columns of two different tables related to foreign key: For example: Client table id | nome | end_cep 1 | carlos | 69084555 2 | Maria | 69088555 Address…
-
2
votes1
answer67
viewsSelect with a return of several values from several columns
Greetings! This is my first post, I hope I can be helped and also help a lot in this journey with you! So any formatting error ask only patience until the patterns here are adequate! Well, my first…
-
2
votes1
answer988
viewsEdit select by displaying bank value and showing other table options
I have the table that registers a user (gr_entity) and has a link with a user status table (gr_entidade_status). I want the editing form (editando_user.php) to show the value that is in the…
-
2
votes1
answer257
viewsC# How to Select and Color all text within a given line in Richtextbox?
In C# I have a Richtextbox, inside it has several lines, what I want to do is select all text within a certain line and color. What I’m doing is this: richTextBox1.Select(0,…
-
2
votes2
answers266
viewsSelect returning dates in the object other than what is registered in the Mysql database
I have a problem when I list the contents of a table and store in a list the date is one day less. I’ve done a lot of research on the web and can’t find a solution to the problem. Below the method…
-
2
votes1
answer864
viewsUsing data from one select within another?
Two tables tbl_orcamento and tbl_itens the budget table has a column with the following status. 1 = orcamento aprovado 2 = ordem de compra emitida 3 = ordem de compra aprovada To tbl_itens has some…
-
2
votes1
answer40
viewsLooking for similar items when using an intermediation table?
Following some advice to optimize queries in Mysql, I decided to split a list of items into 3 tables: Table anime: +----------------+-------------+ | id | titulo | +----------------+-------------+ |…
-
2
votes3
answers89
viewsproblem with select case
I am selecting with case comparing different status of the same field and counting them in separate columns. The problem is that the first column is NULL until the list of the second finishes…
-
2
votes1
answer147
viewsGroup empty case when sql cells
I am making a query in the database to know in which branch the customer paid a installment and what is the normal value and interest that were paid. The value of the tranche is transaction 3 at the…
-
2
votes1
answer63
viewsHow to make a JPA query with mappings @Manytomany
Good morning. I’m having trouble performing a query in the database where my Employee entity has 2 mappings @Manytomany and 1 mappings @Manytoone. When performing a query the Employee and Projects…