Questions tagged [where]

1

votes
2

answer
135

Views

Mongoose populate where

I have two models - M1 and M2. In M1 I have an array of M2 objects. I'm trying to create a query that will grab a bunch of M1 models but ONLY if a certain field in M2 matches the criteria I set. I've setup the models correctly (so M1 has an array of Schema.Types.ObjectId for M2). Ideally I'd want t...
user1157885
1

votes
0

answer
23

Views

Rails 5.1: using { where(association: @assocition) } now requires _id?

A transaction_record has many documents. class TransactionRecord < ApplicationRecord has_many :documents end class Document < ApplicationRecord belongs_to :transaction_record end Previously in Rails 4.2, I could do: Document.where(transaction_record: @transaction_record) and it would return the resu...
Dan L
0

votes
1

answer
13

Views

How to use multiple $or in sequelize

Im writing a query where i need multiple 'or' statements. this is my whereClause: { date_added: { '$lte': '2019-04-18', '$gte': '2019-04-11' }, '$or': [ { id: [Array], secondary_id:[Array] } ], '$and': [ { channel_type: [Object] }, //i need this to be a second $or such that there where statements...
user3662456
1

votes
0

answer
24

Views

Search by date even if date is not in table

I make a select in MySQL and search between 2 dates and make a count of elements by date and it works fine but, if a date has no records it does not appear, what I'm looking for is something like this: Column date / Count 2017-01-01 / 1 2017-01-02 / 2 2107-01-03 / 0 *Date without r...
1

votes
1

answer
114

Views

Using whereInStrict() in laravel 5.5

I tried using whereIn() in my project but because of its loose comparison it considered a value '1gb' as integer. So as per the documentation I used whereInStrict(). $spec['vals'] = ['1 gb', '2gb', '8gb']; // array created by explod() ProductSpecification::whereInStrict('value', $spec['vals'])...
Harikrishnan NG
1

votes
1

answer
17

Views

Conditional WHERE statement to show a certain Fiscal Week Number

Looking for some guidance on how to best execute this code... Ultimately, I want to insert this into the where clause so that the FSCL_YR_WK (i.e. 201804) will be driven based on the current date. AND A.FSCL_YR_WK = Case WHEN GETDATE() between 2018-02-26 AND 2018-03-04 THEN 201804 WHEN GETDATE()...
Master_Sheff
1

votes
1

answer
21

Views

Mysql select statement contains where clause so unsuitable for insert into

I'm very inexperienced. I've prepared a select statement which gives the information I need to populate a matches table. However it is not suitable because it contains a where clause. Is there a different way to use it, or how can I change it so that it is suitable for INSERT INTO. The tables are as...
Liz
1

votes
2

answer
65

Views

How does one retrieve records with all days in date range covered?

Imagine you have something like a action rental or hotel scenario where a unit can have rates for specific days and they can be available or not. I want to be able to search all my units for a specified arrival date and departure date to only bring back units that meet the whole time period. Lets sa...
SolidSnake4444
1

votes
3

answer
308

Views

SQL convert “left join” with a “from” clause with multiple tables and a “where” condition

Image you have 2 tables like this: User: with columns ID, NAME and APPARTMENT_ID. Appartment: with columns ID, ADDRESS. user.appartment_id is a foreign key for appartment.id. With a left join I can do something like: select u.name, a.address from user as u left join appartment as a on u.appartment_...
Lorem Ipsum
1

votes
2

answer
42

Views

How to condition SQL WHERE

I would like to condition when to GROUP_CONCAT my results. I can't figure out the way how to separate my 'category' and 'condition' results. SELECT d.company_name AS 'organisation name', GROUP_CONCAT(DISTINCT tag.tag) AS 'category', GROUP_CONCAT(DISTINCT tag.tag) AS 'conditions', d.contact_describti...
PWT
1

votes
0

answer
35

Views

Alternate of OR with secondary index : cassandra db

I am working with the SELECT query where OR operation is needed on field, lets say hair-color so query looks like SELECT * from persons where hair-color = 'black' OR hair-color = 'brown'; There are only strict operations like AND but no OR unless hair-color is a primary key and alternatively i can u...
1

votes
1

answer
50

Views

Where condition with linq dynamic built at runtime to read xml

I've a problem with a query in linq (lambda expression) to read a complex and large xml file embedded in my software. At bottom of post can find the structure of single field 'PRODOTTO', but there's about 2800 entries like this in the xml. The problem is the where condition. I need to add more condi...
Leonardo
0

votes
0

answer
14

Views

IS NOT NULL is still returning null values in my query

I am using Loader for a query using CursorLoader and the appropriate parameters to derive values. I am using a recyclerview to display data. Without the use of IS NOT NULL in my SELECTION parameter, which is the same as a WHERE clause my recylerview shows 2 blank rows. When I add IS NOT NULL in my...
NVA
1

votes
2

answer
179

Views

ElasticSearch: Creating a bool query with OR AND clauses

I am trying to convert a sql query to its equivalent elasticsearch query ( the sql tabel and ES index are similar). Its a combination of AND/OR. I have a SQL query such that SELECT DISTINCT N_ID FROM MYTABLE WHERE ( [C_ID] = 4 AND E_ID = 765) OR ( C_ID = 6 AND E_ID = 642 )) This is my equival...
Fizi
1

votes
0

answer
36

Views

Postgresql join sub or where sub

My tests give the same run rate. I'm trying to figure out that it's best to use join or subquery. I understand that much depends on the data, the indexes, and the DB itself, but I want to distinguish it so if the records in t1 are less than t2 then the subquery should be effective, but if on the con...
Yaroslav Malyk
1

votes
2

answer
459

Views

Strange “misuse of aggregate: max()” error in SQLite

I have SQLite table with very simple structure: CREATE TABLE `test` ( `id` INTEGER, `val` TEXT ) I want to select only max id where val field value is equal to string 'test_id': SELECT max(id) AS test_id FROM test WHERE val = 'test_id' // (1) Please note that I use 'test_id' string in WHERE and tes...
1

votes
1

answer
41

Views

SQL query to see changes in user types

In an [order] table, some rows have the same user_id but different fee, meaning that they switched from basic to premium over time, or vice versa. Basic pays zero fee, and premium can choose different monthly subscription plans. I am trying to see the number of users switch from one plan to another...
user9747483
1

votes
3

answer
56

Views

SQL Convert one column into two based on another column

With the following Data Set: Extender_Record_ID: 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 Field_ID: 100, 101, 100, 101, 100, 101, 100, 101, 100, 101 Date: 1/1/2018, 1/2/2018, 1/14/2018, 1/15/2018, 2/1/2018, 2/3/2018, 2/15/2018, 2/17/2018, 3/2/2018, 3/5/2018 I am trying to get an output of: Start Date: 1/1/2018...
Cliff
1

votes
1

answer
35

Views

Python Log error 'NonType'

I' m new to python and would like to ask the following: I get this error message bad operand type for unary ~: 'NoneType' when I'm running a very simple data step as: df['new_FLAG'] = np.where(~(df.var2.str.contains('Test|Random|Hypo|Sample',case = False)) & df.var3.isin(['CLIENT_CURRENT', 'MODEL_...
Chrissie M.
1

votes
2

answer
24

Views

SQL: variable values inside of a where clause, or similar?

Situation: Trying to get payrate of employee at 90 days after hire, and 1 year after hire. I've been trying something like this: SELECT payrate FROM dbo.table WHERE (table.checkdate BETWEEN table.startdate +90 AND table.startdate +97) I know the above is far from valid, but it's just a quick example...
Christian Love
0

votes
0

answer
2

Views

Adding a wildcard in Query where clause? (Access '16)

My Query pulls records based on a few different unbound fields in a search form. For the searchable fields, I use the following in the criteria second of each query field: Like Nz([field_in_search_form], '*') For the Name field, I'd like the end user to type 'Tony' and get results such as 'Tony', 'T...
Ebartsch
1

votes
1

answer
36

Views

SQL - Insert in a single Table different Count from another Table

From this table, FLAG CONO MMS001 100 MMS001 100 MMS001 300 MMS001 700 MMS001 700 MMS001 700 I would like to Count the number of '100', '300', '700, and '800' in the column 'CONO', and insert into a single table, like this one : NB_ROWS NB_100 NB_300 NB_700 NB800 6...
Hich
1

votes
1

answer
169

Views

Conditionally fill column based off values in other columns in a pandas df

This question is similar to a few questions regarding conditionally filling of columns but my df is a bit more complex. I have a df with columns that contain floats and strings. I'm trying to conditionally fill the column that contains floats based off the strings. Based on the df below: If the valu...
1

votes
1

answer
61

Views

How to execute laravel WHERE along with EloquentFilter

I am using this EloquentFilter to filter Database on the frontend and the controller below works public function indexArtisan(Request $request) { $workers = Worker::filter($request->all())->get(); $states = DB::table('states')->pluck('name', 'id'); return view ('artisans', compact('states'))->with([...
Umar745
1

votes
0

answer
62

Views

Query ServiceFeatureTable with CreationDate in whereClause in ArcGIS java

I am trying to query the ServiceFeatureTable using ArcGIS java. If we use REST service to query we can query based on the CreationDate. I am trying to do the same thing using ArcGIS java. runtime SDK as below ServiceFeatureTable featureTable = new ServiceFeatureTable(url); QueryParameters query = ne...
1

votes
0

answer
43

Views

SQL query with the condition of equality with the value of the drop down list

I work in MS Access with the query in sql. I have table where in one of the fields is drop down list connected to the multiple values from other tables (multiple values are shown in list as well). How is it possible to set condition of checking equality with the values in the DD list in the WHERE c...
lisa
1

votes
1

answer
934

Views

Where not Exists en Laravel

Could anybody tell me what error I might have in my laravel query, basically what I want is to list the records of a table whose id is not related in another table. I did it in Mysql with this query: SELECT * FROM item WHERE NOT EXISTS (SELECT null FROM qualifications WHERE grades.item_id = item.id...
1

votes
1

answer
57

Views

XQuery - Get only the Query Value

I'm very new at XQUERY... I've an element from a XML file like this: And I'm using XQuery in order to get the queries that have INSERT INTO. So from my XML file I've to receive this this: SELECT * FROM tableA I am trying with this code to get that: for $x in doc('C:\XXXXX.item') where matches($x, 'I...
SaCvP
1

votes
1

answer
26

Views

I try to get information from 4 different tables of the same database

In order to create a list of data, I try to get information from 4 different tables of the same database, using php and only one sql statement. The tables are linked together as follows with foreing keys: P and B have their primary keys as foreing keys in D. T has its primary key as foreing key in...
Thanasis
1

votes
2

answer
67

Views

how to match these records belonging to 2 different tables

I have 2 tables (2008 mssql database), lets say x.dbo and y.dbo x.dbo has a field name called 'customer name' and y.dbo has a field name called 'customers'.. what I want is filtering the customers that match all and that partially match..(2 of the conditions together) here is my query: Select x....
Melih Cavli
1

votes
2

answer
36

Views

Multiple Case conditions in where clause

I have a table where there 2 columns. F1 and F2. Now F1 has Id and F2 has score. F1 Score 1 10 1 20 6 10 now I want to have a where clause where it considers 6 as 1 and adds them with 1 for example when I use when F1=1 it should give F1 Score 1 10 1 20 1 10 I have used WHERE (F1 = CAS...
Fhd.ashraf
1

votes
1

answer
45

Views

subquerying in WHERE/Joining 3 tables, 2 for records and one for number, returns no result/fails - MSAccess

My query does return any records. Depending on how I write it, it returns no records or all records, although I don't have the code that just returned everything. I need to pull data from two sources with actual records, and a third table which has project-wide information not specific to any record...
Chris Oyer
0

votes
1

answer
16

Views

mysql select multi rows equal from row

I have two tables: TableA TableB ID_A ID_B P1 Text P2 P3 P4 TableB ID_B Text 1 Bla 2 Blabla 3 Bla bla ecc 4 Bla Bla 5 Bla bla Bla 6 Bla bla bla bla 7 Bla bli TableA ID_A P1 P2 P3 P4 1 5 6 6 6 SELECT ID_A,...
carmelocony
1

votes
1

answer
265

Views

expdp where clause errors

I'm attempting to do an export dump based on a query clause. The table holds 2.37bil rows and i need to dump a subset of those. Here is my parfile DIRECTORY=EXPSOURCE DUMPFILE=obs_fact_%u.dmp PARALLEL=4 TABLES=schema1.observation_fact QUERY='schema1.observation_fact:'WHERE concept_cd < ''ICD10CM:N93...
phemor
1

votes
2

answer
71

Views

Ruby HAML add If Condition to each.do

I have a haml ruby site that is pulling data from Salesforce. What I need to be able to do is to set an if condition based on the productCode listed in SF. The each.do establishes a loop to display the related data for each record in the loop. The client would like productFamily specific pages....
Kelly Pedrick
1

votes
1

answer
39

Views

How do i merge Multiple WHERE in SQL (STUCK)

How do i merge this 2 data together to get data like this SELECT A.schlvl AS School, COUNT(DISTINCT A.name) AS NoOfChild ,SUM(B.cat_id=1) AS Picture FROM child AS A INNER JOIN question AS B ON A.child_id=B.child_id WHERE B.answer=0 AND B.cat_id=1 GROUP BY A.schlvl SELECT COUNT(DISTINCT A.name) AS...
Yongs
1

votes
1

answer
95

Views

sql group_concat and where in get inverted results

I'm having a hard time with a query. If I run this (1st bimester only): SELECT subject.name as subject, GROUP_CONCAT(evaluations_mark.note) as mark FROM evaluations_mark LEFT JOIN subject ON evaluations_mark.subject_id = subject.subject_id LEFT JOIN user ON evaluations_mark.user_id = user.user_id...
Daniel Grunblatt
1

votes
2

answer
376

Views

Using whereIn and where in Laravel eloquent query builder

I have been trying to do a query with laravel eloquent query builder but without success. This is what I want to achieve: I have a webshop with laptops. People can search by brand, screen diameter and processor. My table is called 'laptops' with columns 'specsTag', 'screen_diameter' and 'processor'...
B.Kingma
1

votes
0

answer
57

Views

Rx - Where method causes memory leak?

I've created simple trigger based on Rx interval. It generates signal every specific interval and it is filtered by Where method like this (simplified example): var isActive = false; Observable.Interval(TimeSpan.FromMilliseconds(1)) .Where(_ => !isActive) .Subscribe(_ => { isActive = true; Console.W...
Lukas
1

votes
2

answer
54

Views

Where clause with no result

I'm using an SQL query on a double precision column but I get no ressult. select * from chicago_2po_4pgr where f_estimated=38867.0150708261 I'm sure that the row with f_estimated=38867.0150708261exists. I tried to modify the query and use the solution mentionned in enter link description here but it...
Ben

View additional questions