querying

SQL Beginner Query Logic With 3 Tables

白昼怎懂夜的黑 提交于 2019-12-24 18:43:55
问题 The sql tables are as follows: likes with columns drinker and beer, sells with columns bar and beer and frequents with columns drinker and bar. I have previously answered the following statement: "Drinkers who frequent bars which serve some beer they like" with the SQL Query: SELECT DISTINCT y.drinker FROM likes a, sells, frequents y WHERE a.beer = sells.beer AND sells.bar = y.bar AND y.drinker = a.drinker; Now, I am trying to modify the query listed above to answer a similar, yet different

Is it possible to get contents of copy_to field in Elasticsearch?

不羁岁月 提交于 2019-12-23 07:47:25
问题 I'm using Elasticsearch v2.3.0. Suppose I have an index with mapping: { "mappings": { "post": { "dynamic": false, "_source": { "enabled": true }, "properties": { "text": { "norms": { "enabled": false }, "fielddata": { "format": "disabled" }, "analyzer": "text_analyzer", "type": "string" }, "subfield": { "properties": { "subsubfield": { "properties": { "subtext": { "index": "no", "analyzer": "text_analyzer", "type": "string", "copy_to": "text" } } } } } }, "_all": { "enabled": false } } } So,

MongoDB: Error executing stored JavaScript function

好久不见. 提交于 2019-12-21 17:15:53
问题 When I run below stored JavaScript function I get errors: > db.system.js.save({_id:"last_n_users", value: function(n){return db.users.find().sort({created_at:-1}).limit(n)}}) > db.eval("last_n_users(10)") Here is the errors: { "value" : "DBQuery: store.users -> undefined" } Why? Please help me? 回答1: The find() function returns a cursor, which can't be returned from JavaScript. The suggested workaround is to use toArray() to get an array return value. Example ... before : > use admin switched

SQLAlchemy: several counts in one query

混江龙づ霸主 提交于 2019-12-21 07:36:37
问题 I am having hard time optimizing my SQLAlchemy queries. My SQL knowledge is very basic, and I just can't get the stuff I need from the SQLAlchemy docs. Suppose the following very basic one-to-many relationship: class Parent(Base): __tablename__ = "parents" id = Column(Integer, primary_key = True) children = relationship("Child", backref = "parent") class Child(Base): __tablename__ = "children" id = Column(Integer, primary_key = True) parent_id = Column(Integer, ForeignKey("parents.id"))

System.OutOfMemoryException - when Entity Framework is querying a too big data of Varbinary type

删除回忆录丶 提交于 2019-12-20 02:09:06
问题 I'm trying to query a varbinary column that contain a file (1,2 Gb). I'm using Entity Framework. See below: Database to test CREATE TABLE [dbo].[BIGDATA] ( [id] [bigint] IDENTITY(1,1) NOT NULL, [BIGDATA] [varbinary](max) NULL, CONSTRAINT [PK_BIGDATA] PRIMARY KEY CLUSTERED ([id] ASC) ) ON [PRIMARY] Data to test (any file with 1 Gb) INSERT INTO [dbo].[BIGDATA]([BIGDATA]) VALUES ((SELECT BulkColumn FROM OPENROWSET(BULK N'C:\BigTest.txt', SINGLE_BLOB) AS Document)) Controller to download file

Query users by name or email address using Firebase (Swift)

谁都会走 提交于 2019-12-18 16:53:15
问题 I'm quite new to Firebase and Swift and I'm having some trouble when it comes to querying. So there are basically two things I'd like to do: Query my users and find only those that contain a certain String in their name (or email address) and add them to an array. Get all of my users and add them to an array. The relevant part of my data for this question looks like this: As you can see, I'm using the simplelogin of Firebase (later I'd like too add Facebook login) and I'm storing my users by

Eager loading child collection with NHibernate

老子叫甜甜 提交于 2019-12-18 04:29:17
问题 I want to load root entities and eager load all it's child collection and aggregate members. Have been trying to use the SetFetchMode in FluentNHibernate, but I am getting duplicates in one of the child collection since I have a depth of 3 levels. DistinctRootEntityResultTransformer unfortunately only removes the root duplications. return Session.CreateInvoiceBaseCriteria(query, archived) .AddOrder(new Order(query.Order, query.OrderType == OrderType.ASC)) .SetFetchMode("States", FetchMode

Querying array elements with Mongo

…衆ロ難τιáo~ 提交于 2019-12-18 01:33:56
问题 How can I query the smoothies that have apple in them? (below is a collection with 3 documents) _id => 1 name => 'best smoothie' ingredients => Array ( [0] => apple [1] => raspberry [2] => orange [3] => banana ) _id => 2 name => 'summer smoothie' ingredients => Array ( [0] => lemon [1] => mint ) _id => 3 name => 'yogurt smoothie' ingredients => Array ( [0] => apple [1] => blueberry ) 回答1: If you simply run the below query MongoDB is smart enough to figure out what you're trying to do. {

PHP and MySQL: Order by most recent date and limit 10

不羁岁月 提交于 2019-12-17 16:55:25
问题 I am building a notes system on my site and I've got to the stage where users can post notes into the MySQL database using PHP and then PHP prints them out on a page. However, when they print/echo out, the oldest one appears first but I want the most recent first. I also want them to be limited to 10, so only 10 appear on the page. Here is my PHP code, your help will be much appreciated: // initialize some variables $notedisplaylist = ""; $myObject = ""; $result = mysql_query("SELECT * FROM

Check if the event exists before adding it to the Android calender

假如想象 提交于 2019-12-12 18:34:07
问题 I have a list of events in my app. A button on the side lets the user add the event date and time to his/her calender. I use a calender intent to redirect the user to the android calender which the corresponding date and time. Now after the user adds the event to his calender, I would like to disable the 'add event' button which corresponds to the events he/she had already added(so the user avoid adding the same event again). How can I do this? I have gone through the new calender API for