query

How do I update specific fields using a cross reference table?

I'm working on a Glass Types database in MS Access. One Table in the DB lists Basic information about the glass: A unique ID (the "glass number"), description, cost per sq. ft., etc. Table 1 "GlassInfo": GlassNo Description CostSqFt TemperCost LamiCost 0001 "Heavy Glass" 1.38 0.18 0.65 0002 "0001 Tempered" 1.50...

Target mysql query response times

As I'm looking to optimize some of my mysql queries and improve performance, I'm realizing that I'm just not sure what sort of response times I should be aiming for. Obviously lower is better, but what do you normally target as a 'slow' query for a consumer site? My queries are currently running between 0.00 to 0.70 seconds. I assume...

How does a PreparedStatement avoid or prevent SQL injection?

I know that PreparedStatements avoid/prevent SQL Injection. How does it do that? Will the final form query that is constructed using PreparedStatements will be a string or otherwise? ...

SQLite gurus: how can I display very detailed metadata about a file?

I have a situation where a simple query against a table is returning incorrect values in Flex, but not in other GUI front-ends to SQLite. select title from ttl where ttl.ttl = 140 // ttl is also the column name of the PK column is returning the title that belongs to the row whose PK = 1400. ttl.ttl is defined as int datatype. Again...

MySQL query that computes partial sums

What query should I execute in MySQL database to get a result containing partial sums of source table? For example when I have table: Id|Val 1 | 1 2 | 2 3 | 3 4 | 4 I'd like to get result like this: Id|Val 1 | 1 2 | 3 # 1+2 3 | 6 # 1+2+3 4 | 10 # 1+2+3+4 Right now I get this result with a stored procedure containing a cursor and ...

Filter out rows by hardcoded list in MySQL performance

Hello, I have a hardcoded list of values like: 1,5,7,8 and so on. And I must filter out rows from table that have ID in list above, so I do something like this: Select * from myTable m left join othertable t on t.REF_ID = m.ID where m.ID not in (1,5,7,8...) But when I have more values (like 1000) and more rows (100) in other...

Help mysql grouping

Please help me figure a single query that will transform the data below... |id |status_a |status_b | |+++++++++++++++++++++++| | 1|active |inactive | ...into this one. |status_group |count| |++++++++++++++++++++++++| |status_a.active | 1| |status_b.inactive | 1| edit: If a single pass query is possible then that wil...

Rails Condition Statement Issue

Hi I have no idea why I am having problems with something so simple but this condition statement is just not working. @battalion = Battalion.find(params[:id]) @soldier = @battalion.soldiers(:conditions => ["seniorleader = ?", "No"]) This shows the array of Soldiers but doesn't reflect the condition I have set. I am sure I am doing...

What is the CouchDB equivalent of the SQL COUNT(*) aggregate function?

Yep, I'm a SQL jockey (sorta) coming into the CouchDb Map/Reduce world. I thought I had figured out how the equivalent of the COUNT(*) SQL aggregator function for CouchDB datasets with the following: Map: function(doc) { emit(doc.name, doc); } Reduce: function(keys, values, rereduce){ return values.length; } Which I thought w...

mysql date storage & query performance with php

I've got a database of historical records from WW2 and currently each recorded event's date is stored in one integer field as YYMMDDHHMM. This makes simple tasks like ORDER BY, or searching for all events within a certain time period extremely easy. However, if somebody wants all events that occurred on December 1st in any year of the wa...

MySQL dot-traversal... possible?

So I'm working on a CMS that will allow users to "traverse" through database tables. I'm having some trouble implementing it though, and am wondering if anyone has any suggestions. Table: house name (varchar), town (relationship, using the rel table) Table: town name(varchar), state (relationship, using the rel table) Table: state na...

SQL: deleting tables with prefix

Hello, i know how to delete my tables in MySQL, DROP TABLE but now i need to know how to delete my tables who all have the prefix myprefix_ How to? --I NEED TO DO THIS IN PHPMYADMIN, IN A BROWSER. NO TERMINAL STUFF PLEASE. BATCH STUFF IS ALWAYS APRECIATED.-- ...

nhibernate mapping question

I have a set of tables, with a .hbm.xml for each. I tried to put in a named query but it would not compile. I moved the code to a CreateQuery and get. DB_Portfolio is not mapped [select sum(p.Shares * s.Price) from DB_Portfolio p, DB_Securities s where p.AccountNumber = :accountNumber and p.CUSIP = s.Cusip] The CreateQ...

How to implement a Query with IQueryable in SilverLight

I have two tables customers, pay and want to implement a gridview in silverlight with the outcome of the relationship of these two tables, the query is as follows SELECT Pa.Tipo_Pagare, Pa.Pagare, Pa.Rut, Cli.Nombre FROM Cred_Crexsa.dbo.Pagare AS Pa INNER JOIN Cred_Crexsa.dbo.Clientes AS Cli ON Pa.Rut = Cli...

mysql & php - query for record with all or fewer values, but not more

(SOLVED, SEE END) I need hints on the PHP or MySQL code structure for the following: Let's say you have X unique boxes, and Y types of fruit. Each box can contain one of each type of fruit. Some boxes might have only 2 types, some might have every type. All boxes have at least one type. For the query, the user has a list of checkboxe...

is my mysql query correct? (does not seem like it)

I want to select data between 1 week ago data until today data: SELECT username, email, date FROM users WHERE date(date) BETWEEN (CURDATE() AND (CURDATE() - 7)) ORDER BY userid DESC LIMIT 10 Hope you guys can help me. It does not work!!! This question has been answered by lexu (can somebody close this question?) ...

how to run query that contain ( ' ) ? ex: select * from A where B like 'aa'bb' ??

Hi How do I run a query that contains ( ' ) ? For example: select * from A where B like 'aa'bb' Working on Oracle 10g Thanks in advance ...

SQL: how to select single record for multiple id's on the basis of max datetime?

I have the following SQL table, Id WindSpeed DateTime -------------------------------------- 1 1.1 2009-09-14 16:11:38.383 1 1.9 2009-09-15 16:11:38.383 1 2.0 2009-09-16 16:11:38.383 1 1.8 2009-09-17 16:11:38.383 1 1.7 2009-09-19 16:11:38.382 ...

How to search with multiple criteria from a database with SQL?

Hi. I am a newbie programmer. I have a page looks like below. I have a car database and i have to make a search from database with this page. There are many criterias that Users can enter and select values. But User doesn't have to fill or select all criterias. For example User can search a car that only depends on "Mark" or can search t...

Very basic SPARQL beginner problem (or RDF modelling problem)

Hi to you all (and thanks for this great website since there doesn't seem to exist a forum on beginner-SPARQL-questions), i hope someone can help me on this probably totally easy-to-solve problem: I want to run a SPARQL query against the following RDF (noted in N3, the RDF/XMl sits here). This is the desription of a journal article and...