query

NHIbernate OR Criteria Query

I have the following mapped classes Trade { ID, AccountFrom, AccountTo } Account {ID, Company} Company {ID} Now I cannot figure out a way select all trades where AccountFrom.Company.ID = X OR AccountTo.Company.ID = X I can get AND to work using the following: criteria.CreateCriteria("AccountFrom").CreateCriteria("Company").Add(Res...

Filter list contained in entity returned by jpa/hibernate query

Hi all, I have a simple jpa entity 'ApplicationForm' with a one to many list in it: @OneToMany(cascade=CascadeType.REMOVE, mappedBy="textQuestion") private List<Dictionary> questions; The variable Dictionary contained in ApplicationForm is just another plain entity with just the text of the question. The corresponding database tab...

SQLite Complex Query Help

Hi, I have a very complex query going on in SQLite, and I need a bit of help understanding how to do it. The following example is of my Database: Category: CatID | CatTitle ---------------- 1 | XYZ 2 | Sample Content: ItemID | ItemCatID | ItemText | ItemText2 | ItemText3 | ItemText4 -----------------------------------------...

How to change Access form listbox query

I have a listbox with this query: SELECT [350PressProduction].ID, [350PressProduction].ContinuationOfID, [350PressProduction].RunDate, [350PressProduction].ProdLength, [350PressProduction].ProdWeight FROM 350PressProduction WHERE ((([350PressProduction].RunDate)=#4/15/2010#)); How do I change that query so the date in the WHERE claus...

Get data origin after a UNION

I have a SQL query like this: SELECT * FROM ( (SELECT name FROM man) UNION (SELECT name FROM woman ) ) AS my_table ORDER BY name how can I retrieve the source of my data? For example if my result is like this: Bob Alice Mario ... I want to know if the name 'Bob' is retrieve from the 'man' table or from the 'woman' table. ...

How to refresh relational property of a LINQ class?

Hi, I have two instances of a program that manipulate same Northwind database. When I add some records to the database from one of the instances (for example adding some orders to Orders table with a customer foreign key John), I can query these new records from the other instance of the program properly. The problem begins when I want t...

Need to query "order date" larger than "filled date" any suggestions?

I have a query with over 500,000 rows of data in the output. I need to filter the criteria down so that I am comparing column "order date" to column "filled date". I want to find all orders with a filled date sooner than an order date (yes, that sounds backwards). Is there an easy way to query this in design view? I am not very good with...

Merging two complex queries.

What I ended up doing was taking two SQL queries and using the array_intersect() in PHP to filter out the results: $sql1 = 'SELECT z.*, u.username, u.user_colour, u.username_clean, u.user_avatar, u.user_avatar_type FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u WHERE (( z.user_id = ' . $user->data['user_id'] . ' AND z...

App Engine's filter vs. gql methods

I have a user in my system who has created an entity which I'd like to retrieve. I'm attempting to do this using a filter because it's supposed to be faster than a call to the gql method. However, the filter returns no results and gql works. randy_res = Vote.all().filter('created_by=', randy).fetch(limit=10) randy_res = Vote.gql('WHERE...

How to structure URI query for multiple values for same key?

I'm trying to structure a URI that accesses my data by id. Currently my URIs are query based like so: .../content?parentList=15&type=note How could I structure a similar URI so that I could query for notes in multiple lists? Essentially combining the results of the next two URIs. .../content?parentList=15&type=note .../content?pare...

JPA native query and cache

Hi All, Does native query in JPA (createNativeQuery) supports caching? I am filling my own data transfer object because the sql query joins several tables and takes only several columns form them. Regards ...

Using AND, OR and NOT in Solr Query

HI, I am trying a solr query which is like this +field1:* AND (field2:1 OR field2:10) NOT(field3:value1 OR field3:value2) But field3 part of the query is not making any impact. It still brings record which has value1 or value2 in field3 Why is this ? ...

MySQL/PHP - Would putting quotes around numbers break any queries?

I want to have a generic PHP function that builds a mysql query based on the parameters of the function. Since it is generic the query may sometimes ask for id=123 or name='Bob'. I test out some queries with quotes around numbers, even stuff like WHERE id > '50' + 7 and it worked but I have my doubts that this won't cause trouble down t...

Querying array elements with Mongo

how can i query the smoothies that has apple in it? thanks! (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] => le...

Hibernate queryCount with a condition

Hello, I'd like to make an hibernate query. My old query was like : public int getPublicationCountVote(Publication pub,Boolean voteType){ return HibernateUtil.queryCount(SocialVote.class , new String [] {VOTED_PUBLICATION_ID_FIELD, FOR_OR_AGAINST_FIELD} , new Object [] { pub.getId() , voteType }); } But now, ...

Remove duplicate rows in MySQL

I have a table with the following fields: id (Unique) url (Unique) title company site_id Now, I need to remove rows having same title, company and site_id. One way to do it will be using the following SQL along with a script (PHP): SELECT title, site_id, location, id, count( * ) FROM jobs GROUP BY site_id, company, title, location ...

Query to eliminate multiple rows based on oldest date

Working in MS Access 2003 SP3: I have a query that I am running to find what 'cars' were sold with a date after the delivery date. I have thousands of rows. When it is all said and done, I want to just have a handful of rows for each 'car' and then the oldest date. Any suggestions? CAR DATE ORDERED DATE DELIVERED CUSTOMER NU...

How do I do an LDAP query with JavaScript?

trying to make a sidebar gadget that has an ldap query function, but haven't been able to find very good, or any, useful documentation on the matter. im not hugely experienced with javascript, and know little to nothing about how ldap queries function, so any information at all would be useful. info: host: a.b.c.d.e port: 389 ou: peop...

Query for values from 2 tables where one falls in a range calculated from values in one table.

I have 2 tables. The first one has the columns name, value and offset. The second one has the columns result and calculation. I want to know if there is a way to write a query in access where I would select name, value, result and calculation on the criteria the selected result would be between the selected value+(offset/2000) and value-...

Complex SQL query :: display data inline from multiply tables

Hi i have a proble in finding solution. I have 3 tables: Customer customer_id customer_name Relation subscription_id customer_id Subscriptions One customer can have relation with many subscriptions and i want to display data like so: customer_id, customer_name, subscription_first, subscription_second, subscription_n ...all i...