query

iPhone Stock/Ticker Search

I'm trying to build a financial iPhone app that has a stock search as one of its features. I noticed that the Bloomberg app (and the default Stock app) query online whenever they're looking for stocks. Does anyone know how they do this? I once built a PHP backend that queried the Yahoo Finance API using http requests but I doubt this i...

mysql many to many relation query

Hello, Maybe I am just falling asleep (or not!), but how can you do this: I have a table (many to many), let's say for example with fields key1 and key2, in which I want to select all the key1 that don't have a relation with certain key2. As an example, if I have the following: k1_A --- k2_A k1_A --- k2_B k1_B --- k2_C k1_C --- k2_D ...

random row query optimization in innodb table

$offset = SELECT FLOOR(RAND() * COUNT(*)) FROM t_table SELECT * FROM t_table WHERE LIMIT $offset,1 This works great in myisam but i would like to change this table to innodb (all other db tables are innodb) to take advantages of foreign-keys and avoid table level locking. The primaryId field of this table is a VARCHAR(10) I can't "fo...

weird character in DB resultset

So I'm running a query against my database and looping through the results and getting something like- F.�B.�Webster�Day� in most of the results. Those should be spaces but it must've been something weird during the import/conversion (damn you M$). Is there a quick query I can run against the DB to remove all of those and replace the...

How Update a node attribute in xml using Linq query?

Hai I have An XDocument .All nodes in this document have an attribute UserId. I want to change the value of this attribute 0 to 1. How to do this using Linq query. I used this. MyNewUserPermission.Descendants("menuNode").Single.SetAttributeValue("userId", Me.UserId) It's not Working.Error shows Sequence contains more than one element...

Why doesn't this SQL UPDATE query work?

I know SQL well but I must be missing something really dumb here. This update query keeps throwing an error. The query is: UPDATE pages SET 'order' = 1 WHERE id = 19 The table definitely has a column for order, and it has a record with the ID of 19. The order column is not unique. The error I get is the generic one: #1064 - You hav...

Selecting max/min value from more than one fields

In the following query the start/finish columns are datetime fields. How should I modify this query to get two more columns, one with the min date and one with the max date (of all the 6 datetime fields and all the rows) repeated in each row. Alternatively how could I create a new query returning only these 2 (min/max) dates, for the...

MySQL: a huge table. can't query, even a simple select!

i have a table with about 200,000 records. it takes a long time to do a simple select query. i am confiused because i am running under a 4 core cpu and 4GB of ram. how should i write my query? or is there anything to do with INDEXING? important note: my table is static (it's data wont change). what's your solutions? PS 1 - my table h...

MySQL - SELECT ... GROUP BY ...

id - a_id - a_type --------------------------- 1 9 Granny Smith 2 9 Pink Lady --------------------------- 3 3 Pink Lady 4 3 Fuji 5 3 Granny Smith --------------------------- 6 7 Pink Lady 7 7 Fuji 8 7 Fuji 9 7 Granny Smith Ok, assum...

How to increase last day count query performance

I have a table Products with products and table Sales with all sale operations that was done on these products. These tables are connected by Sales.PRODUCT_ID column. I would like to get 10 most often sold products today and what I did is this: SELECT product.* , COUNT( sale.ID ) SUMSELL FROM Products product LEFT JOIN Sales sale ...

MySQL multi table queries

Hi community. I have a bunch of data ordered by date and each table holds only one month of data. (The reason for this is to cut down query time, I'm talking about millions of rows in each month table) For ex. data_01_2010 holds data from 2010-01-01 to 2010-01-31 data_02_2010 holds data from 2010-02-01 to 2010-02-28 Sometimes I hav...

In Oracle, will a compound index still be used if a where clause contains some additional fields?

So let's say I have a compound index on a table that indexes 4 fields. create index idx_comp_index on mytable ( fielda, fieldb, fieldc, fieldd ); If I query that table using all four of those fields in my where clause plus an additional field or two, will the index still be used? select * from mytable where fielda = 'i' and fieldb ...

LINQ Select Statement

Hi All, I'm developing a web application myself to follow some rssfeeds. My purpose is just learning some ajax and i send data from server to client side in JSON format. I use LINQ for querying data and JSON .NET API for object to string Serialization in the server side. The problem is that because of there exists foreign keys between ...

Rails - Find object listed in a table and get parameters

I'm listing the data from one of my models in a table <% @events.each do |event| %> <tr> <td align="center"><%= button_to "Add", :controller => 'personal', :action => "add" %> </td> <td><%=h event.name %></td> <td><%=h event.description %></td> <td><%= link_to 'Show', event %></td> <td><%= link_to 'Edit', event %></td> <% end %>...

PHP Xpath : get all href values that contain needle

Working with PHP Xpath trying to quickly pull certain links within a html page. The following will find all href links on mypage.html: $nodes = $x->query("//a[@href]"); Whereas the following will find all href links where the description matches my needle: $nodes = $x->query("//a[contains(@href,'click me')]"); What I am trying to achi...

sql query to get earliest date

if i have a table with columns id, name, score, date and i wanted to run a sql query to get the record where id = 2 with the earliest date in the data set. can you do this within the query or do you need to loop after the fact ? EDIT: To be explicit, I want to get all of the fields of that record . . ...

Explain locking behavior in SQL Server

Why is that, with default settings on Sql Server (so transaction isolation level = read committed), that this test: CREATE TABLE test2 ( ID bigint, name varchar(20) ) then run this in one SSMS tab: begin transaction SH insert into test2(ID,name) values(1,'11') waitfor delay '00:00:30' commit transaction SH and this one simultaneou...

func.max get unexpected result?

I've got a table (story_id, votes) with data [(1,3), (2,4)] when I try to do a query... session.query(table.c.story_id, func.max(table.c.votes)).first() i'll get: (1,4) the result I expect is: (2,4) where is the misunderstanding? ...

How to create new column in Access - using query ?

How can I create a new column on an existing table in Access using a query? ...

Help with Query - Access

Hi I have 4 tables: machines, categories, users and usersMAchines machines is linked to categories and usersMachines. Machines -------- idMachine machine idCat Categories -------- idCat category Users -------- idUser nameUser UsersMachines -------- idUserMachine idUser IdMachine To list machines, filtered for any field of 3...