subquery

NSPredicate SUBQUERY results in: [NSMutableSet unionSet] set argument is not an NSSet

a 夏天 提交于 2019-12-11 10:02:02
问题 On an array of Artists I am trying to do filteredArrayUsingPredicate using the below format to only remain with Artists that have at least one Album that has at least one Intro song. albums is a to many relationship from Artist to Album. intros is a to many relationship from Album to Intro. I get an exception saying [NSMutableSet unionSet:]: set argument is not an NSSet . What am I doing wrong? Here is the aforementioned predicate format: @"SUBQUERY(albums, $alb, ANY $alb.intros != NULL).

Reference to outer query in subquery JOIN

放肆的年华 提交于 2019-12-11 08:13:46
问题 I'm calling on for MySQL warriors here. My problem is that I need to use a reference to an outer query's table within a left outer join in an subquery. I know this is not possible, but I have no idea on how to replace the subquery filtering with the typical joins in the outer query. I'll take a typical example to illustrate my issue. It's the Olympic games, I have several teams (say table tennis teams) in which there are 1 to N players. A match between two teams is finished when all of its

MySql Combine two queries (subselect or join or union)

我只是一个虾纸丫 提交于 2019-12-11 07:46:14
问题 I have two working queries that I would like to combine to provide one lot of output for a wall display. I am NOT a DB person by any means but have managed to create these queries from scratch, albeit with a lot of info from here! I have four tables with relevant columns: Hosts[host, hostid] Items[hostid, itemid, itemname] History_unit[itemid, value] History_log[itemid, value] hostid and itemid are our identifiers The history_xxx tables are just that, and entry for every record of that data.

MySQL Arrays: Can this be done?

别来无恙 提交于 2019-12-11 07:45:11
问题 Is it possible to select the concatenation of all the results returned by a subquery? So if the subquery returns more than one row, I can somehow get all the results contained in a single string? 回答1: Sort of. What you can get is the concatenated result of all the rows that were grouped together using GROUP_CONCAT. You could use that to employ GROUP BY by a column that you know would group the result set correctly and then using the function to return the concated groups. The manual page

MySQL select with sub-query and LIMIT [duplicate]

蹲街弑〆低调 提交于 2019-12-11 07:36:02
问题 This question already has answers here : LEFT JOIN query not returning all rows in first table (1 answer) Left Outer Join doesn't return all rows from my left table? (2 answers) Closed 3 months ago . I am using the subselect to get the row IDs I need like this: SELECT p.id, c.id as category_id FROM (SELECT id FROM products p WHERE p.id > 6319055 ORDER BY id LIMIT 1000) prods LEFT JOIN products p ON p.id = prods.id LEFT JOIN categories c ON (c.id = p.category_id) WHERE c.active = 1 The ID

MySQL View with a SubQuery

主宰稳场 提交于 2019-12-11 07:26:45
问题 I have the following view that I need to port from Oracle to MySQL. This works perfectly in Oracle, but not in MySQL due to a subquery cannot exist in a view error. How can I convert this to make it work in MySQL? If I am to make another view for this, how would it impact performance? Is it advisable? If so, how can I do that? If a 2nd view is not that great of an idea, how to convert this? Thanks for your help! CREATE OR REPLACE VIEW view_name (var1, var2, var3, var4, var5) AS SELECT SUM(A

Problems to optimize large query and tables structure

六月ゝ 毕业季﹏ 提交于 2019-12-11 07:07:48
问题 I'm not an DB expert, so I've been around for a while, reading as much as I can and thanks to the community answers I could make several changes to my query and tables structure. Even after reading a lot of stuff I got stuck, so I came to make my first question. I have a website where the users post their own stories. Each story can have genres, warnings, multiple authors, multiple characters assigned, etc. We're running MySQL 5.x, tables are InnoDB, website written in PHP. Using GROUP_CONCAT

postgresql multiple subqueries

≡放荡痞女 提交于 2019-12-11 06:28:44
问题 I have a task at hand which requires me to return the details of a student who is enrolled in a class taught by a teacher with the surname of Hoffman and I'm stuck. SELECT * FROM Public."Class" WHERE tid=( SELECT tid FROM Public."Tutor" WHERE tname LIKE '%Hoffman'); This returns to me the classes taught by Hoffman but from here I'm not sure where to go. I believe I have to access the 'Enrolled' table and then finally the student table but have tried to no avail. The following query is as far

nhibernate and “NOT IN” in a aggregate subquery

99封情书 提交于 2019-12-11 06:18:13
问题 I've got an entity Reminder which contains a collection of ReminderSchedule . This is my mapping: <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Reminder" table="Reminders"> <id name="Code" type="System.Guid"> <column name="ReminderCode" /> <generator class="guid.comb" /> </id> ... <set access="field.pascalcase-underscore" cascade="all-delete-orphan" inverse="true" lazy="false" name="Schedules" mutable="true"> <key foreign-key="FK_Schedules_Reminders"> <column name=

Optimize slow ranking query

China☆狼群 提交于 2019-12-11 05:53:51
问题 I need to optimize a query for a ranking that is taking forever (the query itself works, but I know it's awful and I've just tried it with a good number of records and it gives a timeout). I'll briefly explain the model. I have 3 tables: player, team and player_team. I have players, that can belong to a team. Obvious as it sounds, players are stored in the player table and teams in team. In my app, each player can switch teams at any time, and a log has to be mantained. However, a player is