query

Hiding "Group By" value in a Content Query Web part

Hello I'm making a Sharepoint 2007 Content Query web part, where I want to group by a field (ArticleSticky), but I don't want to show the field in the webpart. Is there some way I can hide the field in the webpart? Maybe in the XSLT definition ? ...

query optimization

I have a query of the form SELECT uid1,uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM friend WHERE uid1='.$user_id.') and uid2 IN (SELECT uid2 FROM friend WHERE uid1='.$user_id.') The problem now is that the nested query SELECT uid2 FROM friend WHERE uid1='.$user_id.' returns a very large number of ids(approx. 5000). The ...

Simplify a MySQL query

Hi, I have below a working query that needs to be simplified. The reason is that I need to expand it a lot to cover the real application. For each condition (Pos=xxx AND Indata=yyy) the current query doubles in size, and I have a lot of conditions. Also the ON clause will contain many more conditions than in the example.... The real a...

Data type not found error in JDBC connection in java?

I am using Microsoft Access database for storing data. In that, I stored date as "DATE/TIME" data type. While getting date from the following code it produces error.. String sql = "Select prev_date from StaffAdvance where Staff_ID='"+date+"'"; ResultSet rs = st.executeQuery(sql); What is wrong with t...

Problem with SQL Server smalldatetime insert query.

I have the field: APP_DATE (smalldatetime) I'm doing this query: INSERT INTO table (TYPE, CODE, APP_DATE, DATE) VALUES ('APP', '123', '02/10/2010 12.30', GETDATE()) It fails: Msg 296, Level 16, State 3, Line 1 Conversion from datatype char to smalldatetime generated a value not between the interval of valid values. Instruction has...

MySQL query help

Hi I cant figure out any good way to get a list of tag.names and lang which isn't already inserted in combination inside images_urls. My database looks something like this. tags name user_id +-------+---------+ |hi | 1 | |friend | 1 | |friend | 2 | |people | 2 | +-------+---------+ users id lang...

How to handle single character search terms in MS-SQL FreeText searching?

I am having a problem with a FreeText search, currently running on a SQL 2000 server. In a table of approximately 1.3 million rows which contain company names, I am attempting to use a FreeText query. However since SQL Server strips out special characters and single characters when building its index, our code does the same when subm...

Is it possible using JPA to stream results from javax.persistence.Query.getResultList() ?

Hello, I'm new to JPA and I'd like to know if it is possible to stream data from a result set, I mean I do not want to wait that the query is performed to start dealing with first results, for instance in the case of a batch. Is there any possibility using the JPA API or any community adopted workaround ? Eventually using a feature of ...

help in sql count

Suppose I have a table with 2 columns (status and date) like the following: status: U T U U L date: 12 14 15 16 17 Can I (using only 1 SQL statement) count the number of distinct values in the status? That is: count(U)=3 count(T)=1 count(L)=2 count(P)=0 Can I do this with 1 SQL query? Note: I have static values in s...

Move records to another table using LINQ to SQL

I have suddenly faced a problem with moving some records in a SQL Server database from one table to another, using LINQ to SQL. Is it possible to write in LINQ to SQL a query just as simple as this: INSERT INTO Table2 SELECT * FROM Table1 WHERE Selected = 1 GO DELETE FROM Table1 WHERE Selected = 1 GO without using loops and collectio...

Optimisation of volatile data querying

I'm trying to solve a problem with latency on a to a mysql-5.0 db. The query itself is extremely simple: SELECT SUM(items) FROM tbl WHERE col = 'val' There's an index on col and there are not more than 10000 values to sum in the worst case (mean of count(items) for all values of col would be around 10). The table has up to 2M rows. The...

Check if only single record exists.

I have a table with GID ID DefaultA DefaultB DefaultC DefaultD DefaultE DefaultF my requirement is that there should always be one record in the database always. In the front end if the end user tries to update its ok since he will update the existing record.But if he tries to enter a new record I must stop him. ...

PostgreSQL: Log query only on error

I'm getting the error message: "Invalid byte sequence for encoding "UTF8": 0x9f Ok, now I know somewhere my php app is trying to query using that 0x9f character. But I have no idea WHERE. I checked postgresql.conf but I didn't find anything like "log_on_error". There's only the log_statement parameter which causes postgres to log all s...

How can I get insert query to work with two if(isset statements?

On a users profile, there is a comment box that enables other users to post comments on their profile. I am now working on a dynamic comment area that has a changing text box depending on if A. you are looking at your own profile B. looking at someone elses profile C. not signed in at all. I am trying to implement "updates" now when you...

[mysql] where query count result > 0

Hi all, I need to do a query like this: SELECT wposts.ID FROM posts wposts WHERE ( SELECT COUNT(ID) FROM surveys WHERE POST_ID = wposts.ID) > 0 but need it to be working ? ...

mysql query for getting all items and removing one item based on a criteria

so here's what I accomplished right now: given email1 and email2, get all emails that are not equal to email1 create a list of them check if email2 exists in the list if it does return false, if it does not return true Is there a way to accomplish this via a query instead of creating a list and searching if email2 exists in it? (beca...

Django queries: how to make contains OR not_contains queries

Hello. I have to make a query that will get records containing "wd2" substring or not containing "wd" string at all. Is there any way to do it nicely? Seems something like: Record.objects.filter( Q(parameter__icontains="wd2") | Q( ## what should be here? ## ) ) ...

How can I "think better" when reading a PostgreSQL query plan? (Example attached)

I spent over an hour today puzzling myself over a query plan that I couldn't understand. The query was an UDPATE and it just wouldn't run AT ALL. Totally deadlocked: pg_locks showed it wasn't waiting for anything either. Now, I don't consider myself the best or worst query plan reader guy, but I find this one exceptionally difficult. I'm...

Lots and lots of joins in a Zend Query, hopefully just a slight tweak

Apologies for all this code, anyhow Im re-working a query into the Zend query way of working, this is what I have so far: $db = Zend_Registry::get ( "db" ); $stmt = $db->query(' SELECT recipe_pictures.picture_id, recipe_pictures.picture_filename, course.course_name, cuisines.name, recipes.id, recipes.Title, recipes.Method,...

Doctrine wildcard WHERE query?

Hi, Is it possible to craft a wildcard WHERE query with Doctrine, like so: ->where('this_field = ?', ANYTHING); I'd be using this to build a search query dynamically out of unknown user-selected parameters and therefore would need to have the condition in place but capable of accepting the value "anything". To add, I can get this to...