query

Java Oracle insert Query

Hi I am trying to insert user's input in oracle using Java JDBC. I have to use Insert query. Oracle's column type is varchar2. I am able to insert if user is not entering special character. when user enter special character like # ? / and $ it gives exception Please help to parse these special character. i need to use insert query ...

Oracle UPDATEs to Certain Table Hang Indefinitely

I can update some tables just fine, but a certain table I have cannot be updated by either my ASP.NET application or SQLPLUS. Both hang indefinitely. I have to forcibly quit SQLPLUS. I have update statments both in standard OracleCommand objects running a: cmd.ExecuteNonQuery(); but I also have asp:SqlDataSources bound to a GridVie...

How to handle multiple one->many relationships?

I have a database with several tables, 5 of which are dedicated to specific publication types. Each of these 5 have a one->many relationship with a status table and a people table. All of these tables are tied together using a unique "pubid". I have a view which includes the pubid (for all 5 types), along with their associated keyword...

mysql query with group by and order by

I have a table like this: .--------------------------------. | Name | XX | Date | .--------------------------------. | N1 | 5 | 2009-05-01 | | N1 | 10 | 2008-01-08 | | N2 | 8 | 2009-02-02 | .________________________________. My result should be this: .------------. | Name | XX | .-------...

writing sql queries

Hello. I am trying to write an sql query and I am having a problem. When we want to write a query with a where clause to narrow down our results, we can do ... where name = 'John' (Where name is a column in the table). Now I am trying to insert a clause like this except the name is "O'Malley". So I thought the query would be ... whe...

How to work with Index on sql server 2008 ?

Hi is it faster to search with index ? if I have this table: MEN: ID|Fname|Age how I insert index to this table how i can search all the person that the age between 20-30 using index ? I work with sql server 2008 thank's in advance ...

Django ORM GROUP BY

This PostgreSQL query solves my problem, but I'm not sure how to put it in Django ORM. SELECT DISTINCT ON (to_email) * FROM (SELECT * FROM invitation_invitation ORDER BY date_invited DESC) AS sub From a list of items, I want all distinct rows for "to_email" column, and where to_email is duplicate, it should select the latest ( date_in...

SQL Server - Selecting Most Recent Record to generate a list of changes

Here is the situation: I have a database of 'tickets', and we track changes to the tickets each time they are saved. I am specifically looking at status changes, which track with the following format: STATUS:{FROM}:{TO} with {FROM} and {TO} changing to the respective statuses. What I need to do is generate numbers by weeks of the amou...

Why does this speed up my SQL query?

I learned a trick a while back from a DBA friend to speed up certain SQL queries. I remember him mentioning that it had something to do with how SQL Server compiles the query, and that the query path is forced to use the indexed value. Here is my original query (takes 20 seconds): select Part.Id as PartId, Location.Id as LocationId F...

MySQL - Find rows matching all rows from joined table

Hi, Table 1: Tracks Table 2: Wordlist Table 3: N:M Track has Words (trackwords) Find all tracks which have all the words. currently the query looks like: SELECT DISTINCT t.id FROM track as t Left Join trackwords as tw ON t.id=tw.trackid Left Join wordlist as wl on wl.id=tw.wordid WHERE wl.trackusecount>0 group by t.id HAVING SUM(...

Sql Server : Column wise total SQl Query

Hi All, Is it possible to get column wise total using query? in my grid there are 20 columns. i have to display each columns total value in its footer. now im using TemplateField field and javascript function to get the total value.if it is possible to get it from sql query i can reduce the code ...

SQLite query in android application

Hi, I use this query in my android database, but It return no data. Am I missing something? SQLiteDatabase db = mDbHelper.getReadableDatabase(); String select = "Select _id, title, title_raw from search Where(title_raw like " + "'%Smith%'" + ")"; Cursor cursor = db.query(TABLE_NAME, FROM, select, null, null, null, n...

SQL Alternative to performing an INNER JOIN on a single table

I have a large table (TokenFrequency) which has millions of rows in it. The TokenFrequency table that is structured like this: Table - TokenFrequency id - int, primary key source - int, foreign key token - char count - int My goal is to select all of the rows in which two sources have the same token in it. For example if my table ...

help with sql date query

I have date field that holds the birthdate. I want to calculate the age somthing like [today] - [born date] How can I do it with a SQL Server 2008 query ? And why does the date look like 01-02-2009 when I need it 01/02/2009; how do I achieve that? Thanks a lot for any help ...

Replace Part of String in MySQL

If i have data in my MySQL like this table: data(TEXT) foo (hal) foo (dave) bar (dave) bar(dave) And i want to do This Query SELECT DISTINCT(data) FROM table; Now this will return the table as listed above. But i want to do is some sort of replace so that my return query should look like this SELECT D...

Generic Java pattern recognition library - like regexps for List<Object>

Is there a library that would let me write regexp-like queries for lists of objects, just like java.util.regexp matches against strings, which are conceptually like lists of characters? I want to be able to use patterns with greedy/conservative quantifiers, identifying groups in matches, etc. Obviously I would have to provide the code f...

Querying Active Directory from Sql Server 2005

How I can query Active Directory from Sql Server 2005? ...

INSERT INTO..SELECT..ON DUPLICATE KEYS ambiguous ids

Hey there, I have the following table: mysql> SELECT * FROM `bright_promotion_earnings`; +----+----------+------------+----------+-------+ | id | promoter | generation | turnover | payed | +----+----------+------------+----------+-------+ | 1 | 4 | 1 | 10 | 0 | | 3 | 4 | 5 | 100 | ...

MySQL query based on 3 tables

Hello. I work with PHP. I have a table named books. In table books I have the book_name with the name of the book, book_publisher with the publisher's ID and book_author with the author's ID. Besides the books table I have the books_author table with the authors names and IDs and books_publisher with the books publishers names and IDs. ...

Mysql Slow query execution

Hi All, I have one procedure which retrieves all the records from one table which has more than 20000 records and two columns. the column i m trying to retrieve has the index on it. But still it takes more than 1-2 minutes to execute. Can anyone provide any input on this. ...