query

Propel: negate multiple conditions

I need to negate multiple conditions at once using Propel. E. g. a corresponding sql condition is: WHERE !(something = 'a' and someOtherThing = 'b') I couldn't find a way to solve this using Propel ORM. Is there a way to build this query with the Criteria-API that Propel 1.3 provides? ...

generating an SSRS report without hard-coding a query

Hello, I've just started working with SSRS 2008 and SQL Server 2008. I am trying to create a report that involves querying about certain sectors and their sub sectors (for example a sector would be something like 'financial sector' and its sub sectors would 'bank', 'transfer'...etc ). However, the sectors and sub sectors are changing s...

TINYINT vs ENUM(0, 1) for boolean values in MySQL

Which one is better, Tinyint with 0 and 1 values or ENUM 0,1 in MyISAM tables and MySQL 5.1? ...

php query function / class

It must be Monday, the heat or me being stupid (prob the latter), but for the life of me I cannot get a simple php function to work. I have a simple query $sql = mysql_query("SELECT * FROM table WHERE field_name = '$input'"); Which I want to run through a function: say: function functionname($input){ global $field1; global...

query with django orm

I need select rows with django orm. I need equivalent of such query select * from order where (user_from = u and f1 not is null) or (user_to = u and f2 not is null) I try to do this way: Order.objects.filter(user_from = self).exclude(f1 = None)+Order.objects.filter(user_to = self).exclude(f2 = None) But no union in orm.. how can be...

Convert query to only use table once

I have the following query: select field1,field2 from #table1 left join (select field3, max (field4) as field2 from #table1 group by field3) a on #table1.field3 = a.field3 I want to change it so #table1 is only used once (and preferably the most efficient way also) Any ideas? Thanks! ...

Make a dual-purpose query, or two separate queries?

This is a contrived example, but consider a scenario where employees have working locations, and where employees have managers who also have working locations: create table WorkingLocation ( ID int not null primary key identity(1,1), Name varchar(50) ) create table Employee ( ID int not null primary key identity(1,1), ...

want to write MS-Access like query builder in c?#

Hi we want to create MS-Access LIKE query parser where user can create complex queries having joins? any thoughts on design in c#? ...

Transact-SQL Query / How to combine multiple JOIN statements?

I'm banging my head on this SQL puzzle since a couple of hours already, so i thought to myself : "Hey, why don't you ask the Stack and allow the web to benefit from the solution?" So here it is. First thing, these are my SQL tables: Fields FieldID INT (PK) FieldName NVARCHAR(50) (IX) FormFields FieldID INT (FK) FormID INT (FK) Va...

CouchDB and multiple keys

Hi, Is it possible to use similiar query in CouchDB? Like use two keys? SELECT field FROM table WHERE value1="key1" OR value2="key2" I was always using only one key. function(doc) { emit(doc.title, doc); } Thank you. ...

mysql if condition

I have to create a query and in that query I need to be able to do this select if(filename is like .jpg/gif) as type from pictures; I basically need to send the type of the picture through but they can be either jpg or gif but I don't know the syntax for the if like condition. tried this and still nothing select fileType, IF(fileTyp...

Help with SQL query

Hi, I have a table with this schema: DeviceID int RoomID int DateInstalled datetime A sample of the table's data looks like: DeviceID RoomID DateInstalled 0001 Room1 1/1/2000 0002 Room1 1/1/2000 0001 Room2 2/1/2000 I need to build a query that will give me the date range each device was locate...

Dynamic Remote Queries (e.g. serializable LINQ)

Hi, I'm looking for possible solutions for the following scenario: I have a service that holds a large amount of data in memory and also updates the data at very high frequency I want to make that data query-able for clients over the internet Ideally, I'd like the client to write a LINQ query on the client side against a proxy objec...

count and remove duplicate access vba

Here is some code I have to remove duplicate occurances of catid & recid in tblcat1_rec table, leaving only 1 entry: mysql = "DELETE FROM tblcat1_rec " mysql = mysql & " WHERE ID <> (SELECT Min(ID) AS MinOfID FROM tblcat1_rec AS Dupe " mysql = mysql & " WHERE (Dupe.catid = tblcat1_rec.catid) " mysql = mysql & " AND (Dupe.recid = tblcat1...

javascript split string on multiple fields using regex

I'm trying to build a handy dsl-ish query ability into my javascript. given: var query = "lastName = 'smith' and firstName = 'jack' or city = 'vancouver'"; what's the most elegant way of parsing this sql-esque string into usable objects such as: [ { field:'lastName', operator:'=', value:'smith', join:'and' }, { field:'firstName...

ruby on rails get url string parameters

I have this url in my database, in the "location" field: http://www.youtube.com/watch?v=xxxxxxxxxxxxxxxxxxx I can get it with @object.location, but how can I get the value of v? I mean, get "xxxxxxxxxxxx" from the url string? Thanks and Regards. ...

postgresql query to show the groups of a user

Hello, If I create a user in a group, like: create role user_1 login inherit in role group_1; later, with which query could I retrieve to which group(s) a user belongs to ? Thanks ! ...

MySQL Query: Select an int field multiple times based on range the numbers fall into

I have an int field in my table scores. It can be a number between 0 and 100. There are over a 1000 rows in that table. I want to select the number of rows that fall between ranges 0-25, 26-50, 51-75 and 76-100. So basically, if this is my scores table score (int) ------------ 10 20 12 56 43 90 87 The output of the query shoul...

SQL to retrieve tree structure nicely

Given the simple data structure: ID | Category_Name | Parent_ID Example: 1 Cars 0 2 Boxes 0 3 Lamborghinis 1 4 VW Camper Vans 1 5 Big Boxes 2 6 Small Boxes 2 7 Cereal Boxes ...

SQL Query Time Coverage

I don´t now if this is the right place for such a question, but I´ll try it :) I have got several sql db entries which represents time periods E.G. Datefrom datetill 2010-10-01 2011-01-01 2011-02-01 2011-05-16 2011-08-08 2011-09-01 I need to test if a given time period ist fully covered from the entries. Is th...