query

How to query google through desktop java app?

I 'm trying to write a simple java desktop app to query google and get the results.I 've read so many articles in the past few days.I know that I have to do it through the gwt (google web toolkit) ,the api that google offers to programmatically query its search engine.My problem is that the gwt seems to be usefull only to construct ajax ...

Hibernate query: find equal objects

Hi, I have a Hibernate class which has a reasonably complicated implementation of equals(). Is it possible to write a query that returns all instances of this class that have at least one other equal object, where equality is defined by the implementation of equals()? Update Evidently this is not possible. As an alternative, is it poss...

How do I get random rows using nhibernate?

How do I select 5 random records using nhibernate. My sql looks like this: SELECT TOP 5 u.UserId, u.UserName, p.ImageFileName FROM users as u, profiles as p WHERE u.UserId = p.UserId ORDER BY NEWID() I tried doing this but it doesn't work IList<User> users = session .CreateCriteria(typeof(User)) ...

Hibernate: Query without SQL-strings?

Hello everyone! Is it possible (and if yes, is it advisable) to do queries of Hibernate-mapped data without using SQL-strings, but some OOP way instead? ...

HABTM Query help

I have a HABTM relationship between 'articles' and 'tags' Problem: I'm only looking for articles with BOTH the tag 'sports' and 'outdoors' but not articles with only one of these tags. I tried this: SELECT DISTINCT article.id, article.name FROM articles inner JOIN tags ON (tags.name IN ('outdoors', 'sports') inner JOIN articles_tags O...

Select Count(*) over large amount of data

Hello i want to do this for a Report but i have 20,000,000 of records in my table and it causes an TimeOut in my application. SELECT T.transactionStatusID, TS.shortName AS TransactionStatusDefShortName, count(*) AS qtyTransactions FROM Transactions T INNER JOIN TransactionTypesCurrencies TTC ON T.id_Ent = TTC.id_Ent ...

Homework: no subquery in getting a value indirectly

I'm having a hard time creating a query for smth that sounds like this: what is the name and color of the items that cost more than grey box detergent(2 attributes: color:grey, type:detergent). NOTE: I'm NOT allowed to user subqueries or use the price as a constant. using subqueries I managed to get this: SELECT name, color FROM i...

SQL check when creating a table

Is it possible to have a CHECK under the form: CREATE TABLE abc (no INTEGER, det INTEGER NOT NULL, quo INTEGER CHECK (quo < AVG(st.quo)), qoh INTEGER CHECK (qoh >= 0)); So basically every time new values are entered to check the average of quo of another (existing) table in the database and if and only if it's lower than the average...

Will the following three queries ALWAYS produce exactly the same results?

hi We want all members who selected category 1 as their favorite category to also have category 9 added as one of their favorite categories. I assume the following three queries will ALWAYS produce exactly the same results ( assuming FavCategory.CategoryID and FavCategory.MemberID form a primary key ): SELECT 9, md1.MemberId FROM M...

MySQL - convert and compare dates on query

I'm working on a football site witch, along with many features, list result tables. The tables are separated between seasons (season name, etc) and rounds (witch are generated everytime a new season starts up, like 2008/2009, 2009/2010, etc) rounds table has a start date and a end date, and the only way I have to dinamically know wich r...

MS-Access - why can't this update query fill empty cells?

In MS-Access database, table called NewTable3 colname is a text column containing lot of empty cells or blanks. i want to put ? character in empty cells . when i run the query UPDATE NewTable3 SET colname = '?' WHERE ISNULL(colname) ; This query updates 0 records why . what is wrong with this query ...

Query To Get Consecutive Events If They Are Close Enough

This is my table structure: monResults: id Int(10) monDateTime Datetime() typeId int(10) I need a query to get all monResults that have consecutive monDateTimes that are less than 1 minute apart and have the same typeId. I want to be able to get X number of these events. Mostly I don't know how to add the condition to make consec...

Running 4 make table queries on a time schedule with no human interaction

I have four make table queries that need to be ran in a certain order and on a daily time schedule. I tried creating a macro that would open them in order but it required human interaction to exit out of the warnings and it failed to move on to the 2nd query. Any ideas? ...

Query Concatenated Field (using SubSonic)

Is there a way to query against a concatenated field using MS SQL? For instance, what I want to do is something like: Select FirstName+' '+LastName as FullName from Attendees where FullName like '%Joe Schmoe%' The above doesn't work. What I have found works is: Select * from Attendee where FirstName+' '+LastName like '%Joe Schmoe%' ...

Separating record returned from function in postgres

I've got a function that returns two parameters as an anonymous composite type via output parameters. I can access the individual columns with a query like this: # select * from guess_user('Joe','Bloggs'); confidence | matchid ------------+--------- 0.142857 | 1121 Now I want to combine the output from this function with some...

How to disable Django query cache ?

In my Django application, I repeatedly run the same query on my database (e.g. every 10 seconds). I then create an MD5 sum over the queryset I receive and compare that to the MD5 sum I created in the previous run. If both are equal, the data has not changed and the web page does not need updating. While I do this, the data in the DB mig...

Linq to LLBLGen query problem

Hello, I've got a Stored Procedure and i'm trying to convert it to a Linq to LLBLGen query. The query in Linq to LLBGen works, but when I trace the query which is send to sql server it is far from perfect. This is the Stored Procedure: ALTER PROCEDURE [dbo].[spDIGI_GetAllUmbracoProducts] -- Add the parameters for the stored procedure...

cancel hibernate query

If user press the "search" button and then they desided to do "something else", we have to cancel already running query. We use Hibernate (and Oracle) as persistence solution. Hibernates Session interface provides cancelQuery() method. After some trys, it seams that cancelQuery() has no effect. Does somebody have some experience this t...

Trying to filter a mysql table by date using a single query.

Hi there, i'm trying to request any records from a table that appear on or after todays date, using a single query. All the dates for each record are stored in seperate columns eg. - one for 'month', one for 'year', and one for 'day'. obviously i've been getting all records that occur after the year in today's date $sql = "SELECT * FRO...

every derived table must have its own alias

i am running this query on mysql SELECT ID FROM (SELECT ID, msisdn FROM (SELECT * FROM TT2)); and it is giving this error: Every derived table must have its own alias. what is wrong ? ...