query

DB2 Increment a value by a certain amount

I need to write a query that increments a value in a table by 3 when run. I would like to do something like this but this doesn't work. UPDATE table SET value = (SELECT value FROM table WHERE condition = true) + 3 WHERE condition = true As in the title this is a DB2 database, any ideas? EDIT: Actually this d...

Query Optimization - Why does this speed up the Query?

I'm using Quest's TOAD for SQL Server on a SQL Server 2000 Server. Here is my query: SELECT CASE SLCE.GroupName WHEN 'Other' THEN ARM.FBCOMPANY WHEN 'Inter Co.' THEN ARM.FBCOMPANY ELSE SLCE.GroupName END AS [Company Name], ARM.fcustno AS [Cust No], ARM.fbcompany ...

Choosing the highest scored results from a table variable in SQL

I have the following table variable in SQL Server 2005: DECLARE @results TABLE (id int IDENTITY(1,1), customerId int, salesId int, score int, lastServiceDate datetime, PRIMARY KEY(id)); I need an efficient way to c...

Easy MySQL question: query with a null value

What am I doing wrong with this query? (Friday afternoon brain freeze...) In WordPress, I used a MySQL query to make an empty custom field called "description" in all posts of a test database, and now I want to add the value "test" to that field. (This is all in the process of teaching myself how to write more complex queries.) But I c...

A script to convert text in a form to query ?

Hello, I'm a total newbie and want to start with php. I know some javascript already. I want to be able to type some text in a form and convert it to a query e.g. In my website there's this search box, I type in 'example' click submit and it gives me this= http://www.externalsite.com/search?s=example&x=0 and pastes it to the addre...

NHibernate custom criterion for an ICcompositeUserType

Hello: Here's a pseudo criteria query I (think) I want to be able to use: public IEnumerable<Allocation> ByResource(ResourceBase resource, DateRange period) { return Session.CreateCriteria<Allocation>() .Add(Restrictions.Eq("Resource", resource)) .Add(Restrictions.IsWithin("MembershipPeriod", period)) .List<...

when to ditch active record?

I'm not new to Rails but I've not done anything quite so complicated as this so far, so I'm curious what a more experienced rails developer might share: I have a sql query which joins 4 or so tables into one output: SELECT places.id, places.name, places.email, places.website, places.blurb, external_ratings.rating, photos.data_file_name...

Help with hooks and taxonomies: Modifying the posts query in wordpress?

in wordpress you can do the following: http://example.com/tag/jazz,blues/ (returns tags page with posts tagged with jazz OR blues) http://example.com/tag/jazz+blues/ (returns tags page with posts tagged with jazz AND blues) I want to be able to do the same thing with other taxonomies other than the "tag" taxonomy. I've created a "mus...

PHP - How to pass a long unescaped string from one page to another?

I would like to pass a long string to a second page. Normally I pass short strings as variables www.example.php?var=something&var2=somethingelse In this case tho I would like to pass a long sentence to a second page and not have to replace all the white spaces with dashes deal with commas and apostrophes. Is there a simple way to d...

SubSonic.SqlQuery Distinct

How do you do DISTINCT with SubSonic.SqlQuery and not Query? I am using Subsonic 2.1 and can't seem to find DISTINCT Thanks ...

Pagination not working Subsonic

I am having trouble with the pagination. It does not work, i.e. List staffs count is always zero for the code below. If I remove the Paged method, correct results appear. How else can I solve this? I am using Subsonic 2.2. Pls help - thanks SubSonic.SqlQuery query = DB.Select().Paged(startIndex, pageSize) .Fr...

MS Access - Query Refactoring Assistance

I have a page in one of my client's websites that generates an extensive report pulling data from numerous tables throughout the website's MS Access database. One of the unfortunate architectural issues of the website is the existence of two nearly identical tables that represent the same "type" of data, but one is an "old" version and t...

MDX - Concurrent calculations based on a "record time range"?

Dear MDX experts, - Is it possible to get the concurrent calculation based on a record time range? Lets say I have; 'start date', 'end date', 'used', and 'color' available... in my fact table.. Is it possible to get the concurrent of 'used' per time (the biggest sum of 'used' that happened during the same range), if yes - what about c...

Storing Data in MS Access and Querying it in Excel

I'm currently on a non-IT project that currently has data which requires some systematic analysis (mathematical formulas). The data is currently stored in Excel but it's a pain to manually enter/massage data in Excel to do the analysis. Would it be better to store the data in MS Access and use Excel to query Access? In other words, st...

MySql and Wordpress query syntax

I'm trying to learn MySQL queries for use with Wordpress.... What I do know is this query, which gives all instances of the custom field "description" the value of "test" if the field is NULL UPDATE `wp_postmeta` SET `meta_value` = 'test' WHERE `meta_key` LIKE 'description' and `meta_value` is null What I need to do is change that so...

How to sort sql result using a pre defined series of rows

i have a table like this one: -------------------------------- id | name -------------------------------- 1 | aa 2 | aa 3 | aa 4 | aa 5 | bb 6 | bb ... one million more ... and i like to obtain an arbitrary number of rows in a pre defined sequence and the other rows ordered by their name. e.g. in another table i have a short seq...

malfunction of FTS usage

hi friends i created a FTS by this article i have a column with type of varbinary(max) that i filled it with MSWord file(.doc) and another column with type of word(filled by .doc). when i run this script , the output is empty SELECT name, content FROM tblWordFiles WHERE FREETEXT(content, '1'); or SELECT name, conte...

Can I re-use an expression in a MySQL query as a variable for another field?

Is there any workaround so I can actually do something like this without having to repeat the entire expression or force a UNION or temporary table? SELECT (complex expression) AS variable1, (complex expression based on variable1) AS variable2 Since variable1 is not defined and available to the 2nd item because of how mysql w...

How bad is my query?

Ok I need to build a query based on some user input to filter the results. The query basically goes something like this: SELECT * FROM my_table ORDER BY ordering_fld; There are four text boxes in which users can choose to filter the data, meaning I'd have to dynamically build a "WHERE" clause into it for the first filter used and the...

Using a SQL Ranking Function with a derived column

I am trying to use a SQL Server 2008 Ranking Function on a query sorted by a derived column. Here's an example SELECT table.FirstName, table.LastName, CalculatedValue(table.number) As Points, ROW_NUMBER() OVER (ORDER BY points) AS 'Row Number' FROM table ORDER BY points I always get an error invalid column name "point...