query

Django: Get all implementations of an Abstract Base Class

I have defined some models which look like this: class ABClass(models.Model): #common attributes class Meta: abstract = True class ConcreteClass1(ABClass): #implementation specific attributes class ConcreteClass2(ABClass): #implementation specific attributes class ModifiedConcreteClass1(ConcreteClass1): #implement...

how to sum multiple sql queries together?

Hi! I'm trying to run multiple queries on multiple tables- similar to "select count(*) from TableA where x=1" per table. What I'd like to do, is get all of the count(*) values that are returned and sum them into a single value... Any ideas? ...

Hibernate query with fetch question

I have a 2 entities in a One-To-Many relationship: OfficeView.java: public class OfficeView implements java.io.Serializable { private Integer officeId; private String addr1; private String city; private String state; private String zip; private List<Devices> devices; getters and setters @OneToMany(mappedB...

what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn't connect to server"); // perform query $query = 'SELECT * FROM posts'; $result = mysqli_query($conn, $query) or die ("Couldn't execute query."); // use returned data while($row...

Linq to Sql supports my string query but not in a property. Can I make it?

I have a class with a title in it. I have a property that returns that title adjusted a bit. If I do Linq to Sql queries off the adjusted title property I get the "not supported" exception. If I do the same thing the property does directly in the linq query it works. Any ideas on how I can make the property work in Linq to Sql? Here is ...

Speeding up lookup of ranges of data from a collection

Say I have a class public class TimestampedTrackId { private readonly int trackId; private readonly DateTime insertTime; public TimestampedTrackId(int trackId, DateTime insertTime) { this.trackId = trackId; this.insertTime = insertTime; } public int TrackId { get { ...

MySQL - Username to connect using Query browser

Hi, I'm fairly new to my sql, and I need to know what is the default username for mysql, like in mssql you have 'sa'. I can connect to the mysql command client but it does not ask me for a username. ...

random sorting each time query is run

in an ms-access database i have a table num weight 1 12 4 13 2 13 6 9 7 13 how can i write a query which will sort the table according to weight in descending order . but the numbers 4, 2 and 7 have same weight (13) , so they must be sorted randomly each time query is run. any help appreciated. ...

Linq To Sql optional Column

My problem in short: I need a functionality to have optional columns in a linq to sql definition. So that linq to sql normally ignores this column within selects and updates etc. But if a select contains a value for this column it should use this value. Long version: The Scenario I've the following tables: If Field.FieldViews.Coun...

PHP - Get a single result using mysqli

I have descided to change from mysql to mysqli part way through a project - and run into this hicup. What is the best way to achieve this: //check if username is taken $result = mysql_result(mysql_query("SELECT COUNT(*) FROM user WHERE username='".$username."'")); I can not find an exact version of mysql_result I have tried this: $re...

How do I write a LINQ query that inverts the grouping of a hierarchical data source?

How would one write a LINQ query which takes a hierarchical source data and transforms it so that the grouping is inverted? Say I have a list of Topic objects each of which contains a collection of Tags which represent meta-data tags on that topic. What I need is to write a LINQ query to basically flip the hierarchy inside out so that I...

Consolidating a COUNT query

I have a page where I am running an initial SQL query to get a list of subjects, then I loop over this query and run two additional queries for each record returned from the original subjects query (I happen to be doing this in ColdFusion, but not sure that really matters). These two additional queries do COUNTs for that specific subjec...

CAML Query find records where parameter does not exist?

I have a sharepoint list which has several fields. It seems that when a field is left blank on one of the records - that attribute is missing on the field when I query the list using a CAML Query. Is it possible to write a query to return the records which do not contain this attribue? Example: id Employee Title description --------...

Authoritative position of duplicate HTTP GET query keys

I am having trouble on finding authoritative information about the behavior with HTTP GET query string duplicate fields, like http://example.com/page?field=foo&amp;field=bar and in particular if the order is kept or not. Most web-oriented languages produce an array containing both foo and bar associated to a key "field", but I would ...

MySQL query need optimization

Hi all, I got this query: SELECT user_id FROM basic_info WHERE age BETWEEN 18 AND 22 AND gender = 0 ORDER BY rating LIMIT 50 The table looks like (and it contains about 700k rows): CREATE TABLE IF NOT EXISTS `basic_info` ( `user_id` mediumint(8) unsigned NOT NULL auto_increment, `gender` tinyint(1) unsigned NOT NULL d...

How do I add a limit to update-query in Zend Framework?

Hey! How do I add the LIMIT 1 clause to an update when using Zend Framework? I'm kind of forced not to use Zend_Db_Table_Abstract::update() since it executes itself unlike the sweet Zend_Db_Select-classes. The reason to do this is just precaution and I think Zend_Db_Table_Abstract::update()'s syntax makes more sense when found in code...

SQL Server 2005 query plan optimizer choking on date partitioned tables.

We have TABLE A partitioned by date and does not contain data from today, it only contains data from prior day and going to year to date. We have TABLE B also partitioned by date which does contain data from today as well as data from prior day going to year to date. On top of TABLE B there is a view, View_B which joins against View_C,...

Is it a way to know whether Index was used for a particular sql query

Sometimes one when creating SQL queries one assumes that one of the Index should be used by the engine when getting the data. But not always. If some of the necessities are absent the engine will probably process the rows one by one. Is it a way (for sqlite) to know for sure that the index was used? I mean in cases more complex than SELE...

Using char index to find numeric values

I have a column on a mysql table that stores mostly numeric values, but sometimes strings. It's defined as VARCHAR(20). There is an index on this column for the first four characters. ADD INDEX `refNumber` USING BTREE(`refNumber`(4)); Since the field is mostly numeric, it is useful for the user to be able to query for values that fall...

How do I build a domain-specific query language?

I have a biology database that I would like to query. There is also a given terminology bank I have access to that has formalizable predicates. I would like to build a query language for this DB using the predicates mentioned. How would you go about it? My solution is the following: formalize the predicates translate into a query lang...