query

SQL LIKE query not working

I'm trying to run the following query against an Oracle DB, but the query is returning 0 records: select * from TABLE where upper(FIELD) like '%SEE COMMENT%' I know this field contains many records with 'See Comment" in it. For example, here is one of the records: =if(and(Robust_Mean>=20,Robust_Mean<=70),.03*(Robust_Mean+29), if(Ro...

Iphone Sqlite3 Query too slow

Hello I'm really stuck with my app. I need to make a simple SELECT on one of my tables with aprox 250.000 rows (50mb) using SQLITE3. When I load with Iphone Simulator the query takes 3 sec aprox. When i test my app on the Device the query takes 90 sec. Unfortunately I can't release my app with 90 sec of wait. Here i post my code: -(void...

question for h2 which is faster?

now I have two choice. I have the same schema for all the data. the record stand for the connection between to hosts.So one record belongs to two hosts. now I do the action that once I need to get the connection of 1 host. I will insert the record in to h2. So if there is a connection between host1 and host2. Everytime I query the conne...

conditionally including queries in an advanced query in zope

I'm building a quite thorough searching mechanism for a zope site. There are lots of different ways of searching, and because it might want to search for multiple values on the same index (and match all of them) I need to do it using AdvanceQuery. I've built my queries like this: if self.text(): text_query = And() for t in self....

performance with IN clause in postgresql

Hello togehter, what are the performance aspects if you have something like this in your query: ... AND x.somfield IN ( 33620,262,394,450,673,674,675,2331,2370,2903,4191,4687,5153,6776,6898,6899,7127,7217,7225, 7227,7757,8830,8889,8999,9036,9284,9381,9382,9411,9412,9423,10088,10089,10304,10333,10515, 10527,10596,106...

Case-insensitive query that supports multiple search words

I'm trying to perform a case-insensitive query. I would generally use __icontains, but since it doesn't support the .split() method, I'm stuck to using __in instead: def search(request): query = request.GET.get('q', '') query = query.lower() product_results = [] category_results = [] if query: product_result...

UPDATE FROM with a JOIN (Large Table Performance) Postgresql?

I'm trying to get the following query to execute at a reasonable performance: UPDATE order_item_imprint SET item_new_id = oi.item_new_id FROM order_item oi INNER JOIN order_item_imprint oii ON oi.item_number = oii.item_id Currently, it doesn't complete within 8 days so we killed it. The query explaination is as f...

SQL query for finding row with same column values that was created most recently

If I have three columns in my MySQL table people, say id, name, created where name is a string and created is a timestamp.. what's the appropriate query for a scenario where I have 10 rows and each row has a record with a name. The names could have a unique id, but a similar name none the less. So you can have three Bob's, two Mary's, on...

Search Query Optimization

I haven't ever dug into cleaning/reformatting search queries too much in the past, at least not more than general security things like preventing sql injection. I am realizing that I should be implementing keywords like AND, OR, NOT, etc... and doing things like clearing punctuation such as apostrophes, hyphens, etc... As when a user ty...

Querying CouchDB documents between a start date and an end date.

I've been trying to figure out how to create a CouchDB view that will let me query all the documents that have a start date greater than A and an end date less than B. Is this possible in CouchDB or another noSQL document store? Should I scrap it and go back to SQL? I'm simply trying to do the SQL equivalent of: SELECT * WHERE [start ...

Correctness of the query

Am interested to know how correct is my query the question is posted here., I doubt If I have written a perfect one, and I wish to ask you all where can I improve my code. Note: I did not want to fill this place up with lot of code, was very brief. Thank you. SELECT a.BookingId AS BookingId, CAST(b.Transa...

Left join in FetchXml?

How do i do a left join using FetchXml? Consider a simple SQL query like the following: select person.name, address.city from person left join address on person.addressid = address.addressid How would something simple like this be done using FetchXml? Currently my FetchXml query looks like the following: <fetch mapping='logical'> ...

mysql ORDER results BY number of occurences in a column

I have a database which will receive a whole bunch of information, but most importantly it will receive a city name for each row. Sample below: id city 1 London 2 Manchester 3 London 4 Brighton 5 Oxford 6 Oxford 7 London I want to SELECT only the city name from thi...

Query for all users except for users with an ID in this collection

I'm trying to find all users except for users with an id that is a member of an array exclude_ids Here's what I have: User.where("id != ?", exclude_ids) This only works when exclude_ids has only 1 element. If it has more than one element, I get this error: ActiveRecord::StatementInvalid: SQLite3::SQLException: near ",": syntax er...

SQL query error or what it can be ?

Hello i have table sitizen(id_citizen,name,sname,age,id_city) i try do query select a.name_city,b.name,b.age from city a,citizen b where a.id_city = b.id_city and b.name = 'DAVE' order by b.age desc expect result like this - NY | DAVE | 65 - NY | DAVE | 12 - NY | DAVE | 3 but see result what i can't anderstand - NY | DA...

Is querying on views slower than doing one query?

Will Mssql be even fast when I query on a view opposed to one query? example When I have this view: create view ViewInvoicesWithCustomersName Select * from Invoices left join Customer on Customer.ID=Invoices.CustomerID What will be faster or will it be even fast? a) select * from ViewInvoicesWithCustomersName where customerName="B...

SQL - condition on field value?

Hi, I would like to know whether I can test some value against a condition in each returned row somehow in the query? e.g.: I have columns: X Y Z -1 1 2 2 2 -1 3 -1 3 I want to use avg() for all values except for -1. I CANNOT use where<> -1 as each row contains it once. ...

Combining two queries in Yahoo YQL

Hey there! I want to get the weather information for a specific location. Right now, I need to calls to get them: The first one translated my current position (lat/lon) to a WOEID, the second call retrieves the Weather information by using that WOEID. Can I combine those 2 queries? The first one is: select * from yahoo.maps.find...

Help with SQL Server 2008 query

Hi I have this table: id name 1 A 1 B 2 C 2 D 2 E 3 F and I need to get this: id qty 1 2 2 2 3 1 ...

Team's work item: what is the straight way for restricting query just to one folder in the project?

Hello. i want to filter the Work-items for viewing just work-items related to one folder of the project. is there any field that will help me? System.TeamProject is just to project name, not subfolders? Thanks. ...