query

How to create LINQ QUERY dynamically?

Hi all! Is there any way to insert part of the code between { } dynamically? LINQ QUERY: var csvdata = from csvline in csvlines let column = csvline.Split(';') select new { produkt = column[0], cislo = column[1], part = column[2], ...

GORM Querying where filter is not a direct attribute of a class.

I am trying to figure out the most efficient / effective way of performing a certain type of query using Grails GORM. This is the scenario where I want to query all of the children / linked items in a many to one relationship. This is a one way relationship whereby the many side used the id of the thing it is linked to. One example in...

sql query to show the name of table in a database

i use "SHOW TABLES STATUS" but what i got only number of table in database ? ...

Database query with relationships in Android

suppose I have the following tables sqlite> SELECT * FROM Artists; ArtistID|ArtistName 1 |Peter Gabriel 2 |Bruce Hornsby 3 |Lyle Lovett 4 |Beach Boys 5 |Supernatural sqlite> SELECT * FROM CDs; CDID|ArtistID|Title |Date 1 |1 |So |1984 2 |1 |Us |1...

Can anyone point me toward a content relevance algorithm?

A new project with some interesting requirements has arrived on my desk. I need to develop a searchable directory of businesses, with a focus on delivering relevant results based on arbitrary search queries. The businesses can be of any niche; there's no one area that is more represented than another. When googling for things like "se...

JDOQL Subquery count problems

I am having trouble with subquery counts with JDOQL (using DataNucleus). The following query SELECT this.price FROM com.mysema.query.jdo.test.domain.Product WHERE (SELECT count(other) FROM com.mysema.query.jdo.test.domain.Product other WHERE other.price > this.price) > a1 PARAMETERS java.lang.Long a1 causes the Exception javax.jdo.JD...

mysql optimisation

Hi guys, I have a photo gallery with 1.5 million photos so we are talking a big database. We want to make it so that people once they have uploaded a photo can upload into several different areas of the site. Photos also have attributes and tags and we have a tables for that as well. here is the layout PHOTO TABLE photo_id image status...

SQL Server combining data question

Hey all I am trying to combine my data into one sum. This is my output right now: Amount --------- $258.0 $400.0 $1011.0 $628.0 $628.0 $340.0 $340.0 $1764.0 of course the total would be $5369. This is the type of output I need Description | Quantity | Price | Amount -------------------------------------------- Fees 8 ...

How do I select all the columns from a table, plus additional columns like ROWNUM?

Hey guys, I'm sure this is an easy question, but I have looked around and haven't found a way to do it. In Oracle, I know it's possible to do a select statement that returns the row number as a column in your result set. Example: select rownum, column1, column2 from table Returns: rownum column1 column2 1 Joe...

How to break queries using regex in php

Suppose I have the following string: insert into table values ('text1;'); insert into table values ('text2') How do I break those queries (get each individual query) using regular expressions? I've found a very similar problem: http://stackoverflow.com/questions/958095/useregex-to-find-specific-string-not-in-html-tag ...but it uses...

c# creating a database query METHOD

I'm not sure if im delluded but what I would like to do is create a method that will return the results of a query, so that i can reuse the connection code. As i understand it, a query returns an object but how do i pass that object back? I want to send the query into the method as a string argument, and have it return the results so tha...

quine (self-producing) SQL query

This is a very interesting wiki article about programs that print their own source code without any access to physical source file (in the filesystem). Examples in the articles include C and Scheme quine programs (yeah, it appears they are called like that). I remember someone asking me long ago (about 5 years) whether I could write an S...

How to calculate percentage of "equal or better" in mysql DB?

Dear All, Figuring out a title for this question was hard, but the following is harder for me. I hope anyone can help. I have a simple MySQL database table. This table is filled with records containing an ID and the number of week-visitors. It has records of 2 year of about 200+ websites. To summarize, I want to be able to know two th...

Collection for storing objects with date

I have some objects with Date parameters. What collection will be best for storing them and later querying for object/objects with particular date ? (like given as a String or java.util.Date format) ? EDIT: I was trying to use TofuBear's solution, but cannot make it work. let's say I am calling my function (which returns Map) with a ...

DOMXpath | Select the innermost divs

Im looking for a way to select the innermost div with PHP for example: <div> <div> <div> - </div> </div> <div> <div> <div> - </div> </div> </div> </div> The DIV's containing the - would be selected in the NodeList Im using DOMDocument...

With JDO, is it possible to query for all objects that implement a particular interface?

I tried using the following query: Query q = getPersistenceManager().newQuery( getPersistenceManager().getExtent(ICommentItem.class, false) ); but got: org.datanucleus.exceptions.NoPersistenceInformationException: The class "com.sampleapp.data.dataobjects.ICommentItem" is required to be persistable yet no Meta -Data/Annotations c...

my mysql result set is duplicating?why

im doing this query on mysql, but its giving me duplicate results sets: this is my query: SELECT u.username, u.picture, m.id, m.user_note, m.reply_id, m.reply_name, m.dt, m.votes_up FROM user u, notes m WHERE m.topic_id =14 ORDER BY m.dt DESC i dont understand why its doing it? please help :)) EDIT: table schema notes{id, user_id, ...

MySQL query alias?

I was reading something a few months ago that would take something like: SELECT first, last FROM contacts where status = 'active' and turn it into: SELECT first, last FROM active_contacts It's definitely not a stored procedure and I'm pretty sure it's not a prepared statement. I'm also positive what I was reading did not involve te...

JPA Query - how to get a specific result set?

In an app based on JPA2/Hibernate/Oracle+Spring+Wicket, I use the following model: public class Item { private String name; private Set<Application> apps; private ... } public class Application { private String applicant; private Item item; private Status status; private ... } The mapping between Item and Application is that e...

Numbering MySQL Result Row

i have a mysql result set like bellow id name --------------------- 1 abc 1 abc 2 xyz 2 xyz 3 pqr now i need to modify the result set so that it would be like as follows: id name --------------------- 1 abc-1 1 abc-2 2 xyz-1 2 xyz-2 3 pqr ...