query

How update order of rows stored in a mysql table?

I want to update the order so that GALLERY goes before PRODUCTS. What should be the query to do this? Sorry for my English. ...

How to query a property of type List<String>in JPA

Lets say we have this JPA-annotated class, with a property of type List. This code is currently working fine. @Entity public class Family { ... @CollectionOfElements(targetElement=java.lang.String.class) @JoinTable(name = "elements_family", joinColumns = @JoinColumn(name = "idFamily") ) @Column(name = "elemen...

mysql query - Need a little help with grouping...

I'm wondering how to write this query, it's a little complicated... This is an example of what's being stored in the table: KID Utype Qtype Qname Resp UID Q24-YYY Case T001 HM-99678 N8944 2455 Q24-YYY Case T001 HM-99678 N8944 9874 Q24-YYY Case F099 HM-99678 N8944 6554 Q24-YYY Case F099 HM-99678 SD789 2331 Q24-YYY Case F099 HM...

is dinstinct an expensive query in django?

Hi, I have three models: Product, Category and Place. Product has ManyToMany relation with Category and Place. I need to get a list of categories with at least on product matching a specific place. For example I might need to get all the categories that has at least one product from Boston. I have 100 categories, 500 places and 100,000...

How to fetch an object graph at once?

I'm reading a book, where the author talks about fetching an row + all linked parent rows in one step. Like fetching an order + all it's items all at once. Okay, sounds nice, but really: I've never seen an possibility in SQL to ask for - lets say - one order + 100 items? How would this record set look like? Would I get 101 rows with mer...

add parameter to google query

Hello, I am trying to get the realtime stockquotes from google for some time now. First I try'd the finance api, but that didd'nt work out. Then I saw this query and it seems to good to be true http://www.google.com/finance/info?client=ig&amp;q=goog It must have some drawbacks that I am not aware off now. Anyway, it does give realt...

Where to place a query to show only one post in Wordpress

The code below shows a Wordpress loop. How can I modify this loop to show only one post on the page? <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="fullbox" id="post-<?php the_ID(); ?>"> <h3><?php the_category(', ') ?></h3> <div class="fullbox_content"> <h1><a href="<?php the_permalink(); ?>" rel="b...

Doing queries with NHibernate

I'm new to NHibernate, so this is a basic question.. When fetching data from the database through an NHibernate session I've only done it using the Id this far, e.g. like this: var customer = Session.Get<Customer>(customerId); But how do I fetch an object based on a property that isn't the Id? E.g. fetch a customer by search on th...

PSQL 8.3+ client query results display

Rather silly question, but I can't seem to find the answer in the docs or man pages. Starting with 8.3 I think, the psql CLI client will not display the results of a large query inline. It pipes to a 'less-like' result viewer that disappears when you hit q. This makes it very difficult to use data from the first query in subsequent que...

Join two tables where all child records of first table match all child records of second table.

I have four tables: Customer, CustomerCategory, Limit, and LimitCategory. A customer can be in multiple categories and a limit can also have multiple categories. I need to write a query that will return the customer name and limit amount where ALL the customers categories match ALL the limit categories. I'm guessing it would be simila...

combine master and detail information in query result

Using openoffice.org Base 3.1.1 Given the database below with three tables, I would like to create a query with the following output. How can this be achieved with queries or views? output book.title, tags title 1, tagdescription1 tagdescription2 tagdescription3 title 2, tagdescription2 database BOOK id - primary key,title 1, title...

TSQL/VB.NET - write stream to a table

Dear Folk's i'm using the following code in order to send the bytes of a picture into the stream table: Dim FirstColumnNames As String = imTable(0) & "_Code, " & imTable(0) & "_Price, " & imTable(0) & "_Title, " & imTable(0) & "_Type, " & imTable(0) & "_Height, " & imTable(0) & "_Width, " & imTable(0) & "_Comments " Dim FirstFieldsValue...

Android - Get All Contacts from All Sources

Hello. I have been attempting to make an Android application, built against 2.0, that requires getting all of the user's contacts and displaying them in a formatted way. I have been able to get a list using a Cursor and the ContactsContract.Contacts class. However, the list I get from that provider only gives me the contacts that are e...

SQL Server get parent list

I have a table like this: id name parent_id 1 ab1 3 2 ab2 5 3 ab3 2 4 ab4 null 5 ab5 null 6 ab6 null I need to do a query with input id = 1 (for an example) and results will be like this: id name parent_id 5 ab5 null 2 ab2 5 3 ab3 2 1 ab1 3 (List all parents at all level start at item id = 1) ...

PostgreSQL: Selecting N result in group by query

Hi, I have following SQL query that selects some results from my table: select avg(c3), count(c3), std from ssims where obraz = 'lena' group by std order by std But I have various number of tests performed for different values of std, so it returns me something like that: 0.906176136363636;44;5 0.881669302325582;43;10 0.855873409...

Associating tables in PHP + MySql

So, i'm creating a money management system. My database has 2 tables: main(id,timestamp,value1,value2) and fields(value1,value2). Value1 and value2 are the categories in which the money are spent. In fact, the script display a table where the rows are the days and the columns are the fields where the money have been spent into (sport, ...

Help modify / optimize database schema / indexes for faster query result when using LIKE and EXISTS clauses

Hello, While implementing a hierarchy / tree structure on a SQL server 2005 database, I'm getting very slow query response ( below queries talking more than 5 sec ) when using LIKE clause combined with the EXISTS clause. The slow queries involve two tables - [SitePath_T] and [UserSiteRight_T] : CREATE TABLE [dbo].[UserSiteRight_T]( ...

LDAP Query with sub result

I have been banging my head for quite a while with this and can't get it to work. I have a LDAP Query I do have working in AD Users and Computers but dont know how to do it programatically in C#. Here are my LDAP Query that works fine in the AD Tool: (memberOf=CN=AccRght,OU=Groups,OU=P,OU=Server,DC=mydomain,DC=com)(objectCategory=user)(...

php mssql_query() fail without any error and only when selecting a particular table

Hi, I don't understand why this piece of code miserably fails. The first pass of the for() loop works fine but in the second pass mssql_query() fails, no errors are reported and the program just die. for($i=0; $i <2; $i++){ $query = "SELECT * FROM Viaggio "; $result = mssql_query($query, $link) or die("query fallita:".msql...

How make a custom query on the fly?

I'm working in a database on vb.net with sqlite wich hosts a gallery and I want expand the search propieties. This the actual query string: "SELECT images.* FROM images JOIN nodes ON images.id = nodes.image_id WHERE tag_id = (SELECT tags.id FROM tags WHERE tag = '" & tagname & "') ORDER BY images."...