query

Help with SQL query (add 5% to users with conditions)

Hi everyone, I’m having some difficulties with a query which purpose is to give users with more than one thread (called CS) in current year a 5% point “raise”. My relational schema looks like this: Thread = (**threadid**, threadname, threadLocation) threadoffering = (threadid, season, year, user) user = (**name**, points) Then, wha...

Transitive SQL query on same table

Hey. consider d following table and data... in_timestamp | out_timestamp | name | in_id | out_id | in_server | out_server | status timestamp1 | timestamp2 | data1 |id1 | id2 | others-server1 | my-server1 | success timestamp2 | timestamp3 | data1 | id2 | id3 | my-server1 | my-server2 | success timestamp3 | time...

a bugging query

i need to get a query where the elements are displayed in case the first letter is E (the word is electronics).. i have tried with the following : mysql_query("select * from nested_category where name like '[A-F]%'"); Edit : its like i need to choose all the elements for which the first element lie between A & F .. I need all the ele...

Group MySQL Data into Arbitrarily Sized Time Buckets

How do I count the number of records in a MySQL table based on a timestamp column per unit of time where the unit of time is arbitrary? Specifically, I want to count how many record's timestamps fell into 15 minute buckets during a given interval. I understand how to do this in buckets of 1 second, 1 minute, 1 hour, 1 day etc. using My...

How to get a dynamic attribute name in cfloop over query in ColdFusion

I'm inside a cfloop over a query. I want to get an attribute, but I won't know what that attribute will be until runtime. Using #qryResult[MyAttr]# fails with the error "Complex object types cannot be converted to simple values." What is the syntax for doing this? Here is a simplified example: <cfquery datasource="TestSource" name="qr...

Select top/latest 10 in couchdb?

How would I execute a query equivalent to "select top 10" in couch db? For example I have a "schema" like so: title body modified and I want to select the last 10 modified documents. As an added bonus if anyone can come up with a way to do the same only per category. So for: title category body modified return a list of...

Average of Average in one row

Hi there, I'm not sure if this is possible what I'm trying to achieve. I want to get the avg of averaged columns. SELECT avg(col1), avg(col2), avg(col3) FROM tbl My Result should be the avg of all three avg columns, is this possible? Something like this SELECT avg( col1, col2, col3) FROM tbl doesn't work at MySQL 5.1 ...

MySQL query killing my server

Looking at this query there's got to be something bogging it down that I'm not noticing. I ran it for 7 minutes and it only updated 2 rows. //set product count for makes $tru->query->run(array( 'name' => 'get-make-list', 'sql' => 'SELECT id, name FROM vehicle_make', 'connection' => 'core' )); while($tempMake = $tru->query->...

VB.NET SQL date is changed format in query

Hi folks, I've got a date variable that looks like this: Dim LogDate As Date = Date.Today.AddDays(-1) the format comes out like: #4/5/2010# then it goes into a SQL select query as a WHERE clause. When I debug, the query has changed this to '05/04/2010'. I want it to be in the format '04/05/2010' like it is when declared. Any id...

Rails - Searching multiple textboxes and fields

I have a model of events that has various information such as date, location, and description of whats going on. I would like for my users to be able to search through the events list through a set of different textboxes but I having a hard time getting the syntax just right in my view I have... <% form_tag users_path, :method => 'get...

Retrieve data using Dynamic Query and Linq to SQL

Hi I have a really complicated dynamic query that i want to use to retrieve data from the database I am working in .net 3.5 sql server 2008 i created a stored procedure that accepts a varchar(max) as input parameter and does execute (@SqlQuery) it executes but does not return anything I really would like to use LINQ as all my proje...

Creating Sharepoint FullTextQuery with dates, especially content publicationdate

Hi, Is there any way to create a fulltextquery with conditions of content publication date? It should select all content, regardless of its type, published between 2January and 4April Select title, url from Scope() where .... ? Is it possible ? ...

CouchDB query performance

If the number of documents is more will the querying of data gets slower in CouchDB? Example Scenario: I have a combobox in a form for customer name. When the user types the customer name, I have to do autofilling. There will be around 10k customer documents in the CouchDB. I understand that i have to create a view to do the same. C...

mySQL Query JOIN in same table

Table structure goes something like this: Table: Purchasers Columns: id | organization | city | state Table: Events Columns: id | purchaser_id My query: SELECT purchasers.*, events.id AS event_id FROM purchasers INNER JOIN events ON events.purchaser_id = purchasers.id WHERE purchasers.id = '$id' What I would like to do, is obvio...

sum of Times in SQL

Hello all, I have some records like this: ID Personel_Code Time --- ------------- ------ 1 0011 05:50 3 0011 20:12 4 0012 00:50 I want to have the sum of times for each person. in this example I want to have the result like this : Perso...

How do I write this Django model in SQL?

I want to create a new column. How do I write this in SQL? class mytable(models.Model): created_at = models.DateTimeField(auto_now_add=True) ...

Simple Android Database Query problem

Hi everyone, I'm new to StackOverflow but so far I love this site. I'm writing an Android application for RC cars. It uses an SQLite Database, and saves the model of the car (carname) as well as other variables. I want to be able to display only the records that have a certain model of car named in the carname column. So far I can only...

Exact matching of strings in SPARQL?

I have this query. It match anything which has "South in its Name". But I only want the one whose foaf:name exactly matches "South" SELECT Distinct ?TypeLabel Where { ?a foaf:name "South". ?a rdf:type ?Type. ?Type rdfs:label ?TypeLabel. } ...

MySQL parameter resource error

Here is my error: Warning: mysql_query() expects parameter 2 to be resource, null given... This refers to line 23 of my code which is: $result = mysql_query($sql, $connection) My entire query code looks like this: $query = "SELECT * from users WHERE userid='".intval( $_SESSION['SESS_USERID'] )."'"; $result = m...

Need Help Writing SQL query

I have two product tables Product1 and Product2. There is a one 2 one mapping on the field ProductId. What I want is to get all the product ids where the Product2.Exported field is false AND Where the product ids that are in Product1 but not in Product2 table. Right now I have two queries that I'm trying to mash into one. SELECT Pro...