Most voted "where" questions
81 questions
Sort by count of
-
12
votes5
answers35616
viewsSELECT condition WHERE with multiple values in the same column
I have two tables in my bank and perform JOIN with them. A table is a list of people and the other characteristic list of that person. By logic there is only one person and each person can have…
-
7
votes1
answer121
viewsIs it possible to change more than one record at a time?
That is the code: UPDATE PESSOAS SET COR = ('Pardo') WHERE ID = 1; But I have 2 more records to do the same procedure, I could do everything at once adding the ID?…
-
5
votes2
answers1524
viewsCondition on Join or Where?
Is there any difference if I use: select * from a left join b on a.id = b.id and b.id2=1 where ... or select * from a left join b on a.id = b.id where b.id2=1 Sent on: Fri ? The first SQL returned…
-
4
votes3
answers162
viewsProblems with SELECT with 2 Wheres
I’m having a bit of an amateur problem here. I’m not getting this SELECT from 2 CONDITIONS, and I can’t find the ERROR! Someone please give me a light there! Follows the Code: OleDbConnection Con =…
-
4
votes3
answers146
viewsPerformance "Where in foreach vs if"
Which case would perform best? var chaves = new list<string>(); foreach(var item in lista) { if(!string.IsNullOrEmpty(item.Chave)) { chaves.Add(item.Chave); } } Or listaValida = lista.Where(x…
-
4
votes3
answers160
viewsSelect Where IN all records
Gentlemen , will searched for days the answers to this doubt that I think is silly , but I could not. I created a view that has Matricula | Name |Job |Shift | Centrocusto | Codtreina | Status I made…
-
4
votes1
answer194
viewsWhere Mysql search by full word
I have a database and would like to know how I do to search for the data by typing the full result using Where Example: ID NOME CODIGOS 1 | Joao | 9714,51,100 2 | Maria | 50,9714,88100 Ai wanted to…
-
4
votes2
answers238
viewsHow to search MYSQL search for word in title and then in text and sort by title first
I have a table with title and content and wanted to do a search to see if the term is in any of these fields. If you have, bring the results of the title first and then the content tabela…
-
3
votes2
answers2034
viewsPassing values from a select to subselect
I have the following query: SELECT rp.colaborador as codigo_, t.nome, count(rp.*) as presencas, ((100 * (select count(rp.*) from empresa.cad_reuniao_presencas rp join empresa.cad_terceiros t on…
-
3
votes1
answer62
viewscolumn does not obey the Where command of an update
I have a problem. At the moment I make an update, when I use Where only the line with the code informed is updated. however the Description field that I report, its content is replicated for all…
-
3
votes0
answers582
viewsSelect from all records of an IN clause in Mysql
I would like your help because I made a simple query that would need to return all records specified in clause IN. In this clause ( TF.Codtrains IN ) it comes from a select. The problem is that it…
-
3
votes1
answer531
viewsSQL select with dynamic Where in ABAP
There is the possibility to create a select with dynamic Where in the abap language?
-
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
answer922
viewsWhy is it not possible to use an "alias" in the WHERE clause in Mysql?
I need to wear a alias in the clause WHERE, but keeps telling me it’s an "unknown column". I need to select records that have a higher rating than X. The rating is calculated as the following alias:…
-
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
votes1
answer83
viewsWhere in datatables with codeigniter
I have a code that draws a table according to the data in the database. EX: If she has a registered customer she will make the table with only one row, if he has no registered customer, no table…
-
2
votes1
answer80
viewsCount records only if larger than the current datetime, with Count()
I have the following query: SELECT u.nome, u.email, u.login, u.data_cadastro, COUNT(*) AS qtd FROM patrocinadores AS p LEFT JOIN anuncios AS a ON a.id_user = p.id_user INNER JOIN usuarios AS u ON…
-
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
votes1
answer294
viewsError Code: 1054. Unkowm column
I’m looking for a value from an account I made in SQL: (Valor - (select Visibilidade)) AS Diferenca When I try to consult: Diferenca <= 500 It presents the following error: Error Code: 1054.…
-
2
votes2
answers485
viewsINSERT INTO with Mysql filter
I am trying to create an INSERT INTO in an X table by making a filter in table Y, but I get a syntax error. I’ve researched what could be wrong, but not found. INSERT INTO products ( SELECT * FROM…
-
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"…
-
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
answers78
views -
1
votes2
answers83
viewsSet of WHERE , AND and OR conditions in SQL does not produce the expected result
I’m trying to get some records with a very simple syntax, but it’s not working. I’m doing something wrong and I’m not realizing it. Can someone lend a hand? I need to fetch all records from 2017…
-
1
votes2
answers2096
viewsFind a string anywhere in the List c#
Good Afternoon. I would like to know how to find a string anywhere in the list. Ex.: string "123". It can be in Pessoa.id, Pessoa.Nome, Endereco.id, Endereco.Rua or Endereco.CEP; People’s List…
-
1
votes1
answer155
viewsQueries Builder Problems (Query Builder) in Laravel 4.2
Hello, I’m having trouble generating a querie using the Querie Builder of Laravel 4.2, the difficulty arises from the need that the resulting sentences for search in the database are within…
-
1
votes1
answer1113
viewsDifference between INNER JOIN, JOIN and WHERE?
I need to perform a query that return me information according to a certain condition, I have always used the Where for not knowing if he could use another method. So what’s the difference between…
-
1
votes1
answer3155
viewsHow to solve the ORA-01795 (maximum number of expressions) error in Codeigniter
I am developing a report in Codeigniter, but my select contains a filter that can have more than 1000 expressions in my where_in and then it returns me the error: ORA-01795: o número máximo de…
-
1
votes1
answer963
viewsHow to check route parameters in Laravel and accepted only specific parameters?
I would like to know how to create a function that validates the parameter received from a route on Laravel, for example, have a route: Route::get('fotos/{user_id}'); where you can only access users…
-
1
votes3
answers49
viewsError query by date
In my application I have a query by date, below is an excerpt from the script tblacesso.HorarioSaida BETWEEN '2017-06-17 00:00:00' AND '2017-06-17 23:59:59' But it is not selecting the data of the…
-
1
votes1
answer43
viewsWHERE do SQL returns unwanted values
SELECT x, y, z, f , g , h FROM torrents INNER JOIN w ON w = x WHERE y = '2' OR y = '7' AND f = '1' AND h < 4294967296 I named the f = '1' in the where so that he returns to me only the values…
-
1
votes1
answer8375
viewsUse CASE in a WHERE clause
I need to use a condition within a filter parameter in a report. Basically the rule is determined by a vachar field that the value of it is’T' or 'P'. I tried a solution like below but it did not…
-
1
votes2
answers1257
viewsFilter in WHERE Postgresql
Good morning guys, next, I’m doing a standardization of some records here in the company. So there are 2 tables. Table A(old records) columns as: id_alvara | logradouro 1 | Rua Sete de Setembro n°…
-
1
votes1
answer28
viewsDoubt regarding the IN in Oracle
I’m putting together a query and bumped into a question. My query is like this: SELECT BASI_030.NIVEL_ESTRUTURA NIVEL, BASI_030.REFERENCIA GRUPO, BASI_030.DESCR_REFERENCIA, BASI_030.CONTA_ESTOQUE,…
-
1
votes0
answers90
viewsRuby on Rails doubts
I have this def no models, I checked with Pry and have values coming normally, however they do not save on the variable @Inventory and below I put the class Inventory also, I wonder if someone could…
-
1
votes2
answers159
viewsHow to separate a letter from a Character in SQL?
I have a variable of type Character Varying(17) and I need to separate one of the characters, for example the third letter, and use it to filter.For example: SELECT * FROM fnord WHERE…
-
1
votes1
answer378
viewsOracle Where case
I need to create a condition in the where according to a boolean. If boolean = true then I will select the lines with higher end values than expected (ConfirmedVolume > ExpectedVolume, etc) if it…
-
1
votes1
answer133
viewsClause Where takes too long
I’m wearing the Laravel 5.6 My model is normal <?php namespace App; use Illuminate\Database\Eloquent\Model; class MyTable extends Model { protected $table = 'myTable'; public $timestamps = false;…
-
1
votes0
answers46
viewsProblem with Where
I’m using Mariadb and I have a clause problem WHERE bank. The query is inside Excel that brings me database periods through the month filter. But I was asked to change it to a time period, only it’s…
-
1
votes1
answer226
viewsSQL query where WHERE has 2 options
I intend to make an SQL query where WHERE has 2 situations, example: SELECT * FROM products WHERE name = "%Explosion%" OR tag = "%Explosion%" In this consultation I would specify that, first the…
-
1
votes1
answer40
viewsReuse of Clause AND (ORACLE)
Eai Galera. I need to run a select where it gets very repetitive my conditions being various joins in the same table, Follows: select elfo.el_field_option_id "Centro de Custo ID", elfo.label "Centro…
-
1
votes1
answer211
viewsTwo conditions in Where do not bring a result
I am doing a query in Oracle Database 12C and I have a problem: I want only products that have address_1 as 'A' appear in my ResultSelect. In the example below the item "code: 312107" it has two…
-
1
votes1
answer31
viewsConvert percentage
I’m having trouble converting % my code: select veiculos , qtd , trunc(qtd / sum(qtd) over()* 100, 4 ) PERC from ( select ent_datahora_entrada , veiculos , count(*) qtd from ( select…
-
1
votes0
answers46
viewsDoubt Beginner WHERE EXISTS
I’m a beginner in the SQL world, I’m learning some functions and I came across a problem where I can’t understand. I have a table medico with the attribute cod_medico. In that attribute is the…
-
1
votes2
answers49
viewsSQL - WHERE using 2 conditions and AND as conditional - Answer is not the expected result
Good afternoon, doubt is very basic. I am counting items from a single table to two specific "classes" (M and N) within the same column (two possible outputs is what I am calling a "class"). When I…
-
0
votes0
answers272
viewsInner Join + Where in Mysql
How to use INNER JOIN with WHERE? I’m making a INNER JOIN with 3 tables. I need a WHERE to return only one record. I am trying as follows: SELECT `*` FROM (`tabela1`) INNER JOIN `tabela2` ON…
-
0
votes0
answers101
viewsbring data from the database according to other data registered
I have a code that brings the database data and generates a table. This data is coming all that are registered, but I need only data with the same user status come. For example: I have a user from…
-
0
votes0
answers51
viewsBring user information to the model
I have a code that lists several reports. These reports are saved in the database and to call them I use the Model in the Codeigniter. Inside the model, I have one where and to make it work…
-
0
votes1
answer448
viewsHow to Select a table row and display information in another table relative to the table?
I’m using this code, but I’m not connecting it properly... I would like to register Payments (payments) for these to appear only when selecting the partner in the table(socio)... String sql =…
-
0
votes0
answers71
viewsQuery with sql does not return when using WHERE
I have a query that should bring the name of users who received a message sent by a user: SELECT msg.msg_content ,usr.user_name FROM message AS msg INNER JOIN usuarios AS usr ON msg.user_id_out =…