query

How to make query on a property from a joined table in Hibernate using Criteria

Hello, I have the following mapping: <hibernate-mapping package="server.modules.stats.data"> <class name="User" table="user"> <id name="id"> <generator class="native"></generator> </id> <many-to-one name="address" column="addressId" unique="true" lazy="false" /> </class> <class name="Address...

Why is doing a top(1) on an indexed column in SQL Server slow?

I'm puzzled by the following. I have a DB with around 10 million rows, and (among other indices) on 1 column (campaignid_int) is an index. Now I have 700k rows where the campaignid is indeed 3835 For all these rows, the connectionid is the same. I just want to find out this connectionid. use messaging_db; SELECT TOP (1) connect...

Django '<object> matching query does not exist' when I can see it in the database

My model looks like this: class Staff(models.Model): StaffNumber = models.CharField(max_length=20,primary_key=True) NameFirst = models.CharField(max_length=30,blank=True,null=True) NameLast = models.CharField(max_length=30) SchoolID = models.CharField(max_length=10,blank=True,null=True) AutocompleteName = models.Char...

Query list items based on what permissions they have

Don't know how to google for such, but is there a way to query all the items where Permissions are unique to listitem These unique permissions contains assignment for specific group X. ...

SQL Query to get Count within a Stored Proc

So i need to figure out how i can get a record count value and use that count as a new value to insert into a table. Ex: In My Stored Procedure @Count int What im looking for @Count to equal "select top (1) _fieldName from _someTable order by _fieldName Desc" Finally insert into _newTable (_fieldName) values (@Count) End ...

using a java.util.list in the query in jasperreport with ireport

I would like to do like: SELECT mat.idmat AS mat, $P{mylist}.indexOf(mat.idmat) AS myorder, ... FROM ... WHERE ... ORDER BY myorder In this sql I have a list who index the position of each element, so i want to order using the list ...

SQL query help - merge a value to all rows in a column

I'm trying to migrate a site from a joomla system to a drupal. The problem is that drupal needs filename and sourcepath in the same row, but joomla only has filename. I'm looking for a way to add sourcepath before the filename in all the rows in that column. I'm figuring it's the UPDATE statement that I should use, but I can't figure out...

Using Treelist Values to Query a Sitecore Item

I have an item named All Recipes that contains recipes named R1, R2, and R3. I have another item named My Recipes that has a treelist field named Recipes and it contains selected values R2 and R3 from the All Recipes item. The query I'm trying to write is for the Items field of an RSS Feed. What is the query syntax to show the items in...

Query to find all the nodes that are two steps away from a particular node.

Suppose I have two columns in a table that represents a graph, the first column is a FROMNODE and second one is TONODE. What I would like to know is that how will we find all the nodes that are two steps away from a particular node. Lets suppose I have a node numbered '1' and i would like to know all the nodes that are two steps away fro...

MySQL calling in Username to show instead of ID!

I have a users table, books table and authors table. An author can have many books, while a user can also have many books. (This is how my DB is currently setup). As I'm pretty new to So far my setup is like bookview.php?book_id=23 from accessing authors page, then seeing all books for the author. The single book's details are all displa...

How do I do this query in MySQL? (datetime)

Suppose I have a datetime column in MySQL. How do I select all that have a datetime within 2500 seconds of the current datetime? SELECT ALL where current_datetime - that_datetime < 2500 ... ...

Remove ' single quotes in Classic asp

Field = "columnName" value = '2,4' query = ""&Field&" in("&value&")" here the query will be : columnName in('2,4') but i want it to be : columnName in(2,4) how to remove the single quotes Please help ASAP ...

SQL Server - stored procedure suddenly become slow

I have written a stored procedure that, yesterday, typically completed in under a second. Today, it takes about 18 seconds. I ran into the problem yesterday as well, and it seemed to be solved by DROPing and re-CREATEing the stored procedure. Today, that trick doesn't appear to be working. :( Interestingly, if I copy the body of the sto...

Search between dates and times in SQL Server 2008

I need to search between dates and times. For example, between date: 30/02/2007, time: 10:32 and date: 21/06/2008, time: 14:19 What is the most simple query for this? Thanks in advance. ...

SQL Query Help: how to select just start and end rows of groups (Oracle)?

(Apologies for the title of this question - I wasn't overly sure how to explain it) Not sure whether this can be done in SQL. Below is a (somewhat truncated) sample of an event log table. EVENT ID DATE TIME --------- ---------- -------- ---- ONE_THING 0006241800 20091109 1719 ONE_THING 0006944800 20091109 1...

STORED PROCEDURE working in my local test machine cannot be created in production environment.

Hi, I have an SQL CREATE PROCEDURE statement that runs perfectly in my local SQL Server, but cannot be recreated in production environment. The error message I get in production is Msg 102, Level 15, State 1, Incorrect syntax near '='. It is a pretty big query and I don't want to annoy StackOverflow users, but I simply can't find a solu...

What is the fastest way for me to take a query and turn it into a refreshable graph of the results set?

I often find myself writing one off queries to either answer someone's question or trouble shoot something and I would like to be able to quickly expose the on demand refreshable results of the query graphically so that I can share these results to others without having to go through the process of creating an SSRS report and publishing ...

Doctrine: Select elements that are related to one or more items in many-to-many relation

I have a category system that is related many-to-many with posts. How can I select a list of those categories that are related to one or more posts? $q = Doctrine_Query::create() ->from('Category c') ->where('<DONT KNOW WHAT TO WRITE>') ->select('c.name'); ...

How to dynamically modify NHibernate load queries at runtime? EventListeners? Interceptors?

I need to modify the query used to load many-to-one references in my model. It needs to work with lazily loaded entities as well. Specifically, I need to be able to further filter this data. Unfortunately, NH will not allow me to filter many-to-one relationships using the built in filtering system (?). I could just be doing something i...

File system query

Is there an easy way to query data in file system? We are storing data in File system (instead of database) Is there a way to query the content of the file system? The data in the file system is stored in xml format. since the data is growing day by day we are finding it difficult to query the content of the files in the file system. Can...