query

HIbernate Query taking very long time

I am trying optimize my code. I fetching the data using hibernate, when i am running the query directly on the database it fetching the results in 2secs, rowcount around 2800. Same query when i fire from my java code takes 8 secs. i have included the code sniplet below. Please help me out on this, its very urgent. Session hSession =open...

MySQL Query for displaying all rows of one table with yes/no if matching other table?

I apologize in advance for the non technincal description on this problem! I have two tables: UsersOptions and OptionsList.. For simplicity sake, OptionsList is below: ID - NAME 1 - Red 2 - Blue 3 - Orange UsersOptions has many rows eg; ID - CLIENT - OPTION 1 - John - Red 2 - John - Orange 3 - Mary - Red 4 - Jill - Blue 5 - Jill ...

Insert values from same table is it possible?

Hi I want to insert a table values from the same table is it possible? Ex : I'm trying to insert like this insert into emplyeee values (select # * from employee) Thanks in advance ...

Query design in Access

I have created three queries and I need to consolidate them into a single query. They all have same foreign keys from another table. My objective is to have all the fields (primary key) from the main table displayed in the consolitated query regardless of whether there is record. Please advise ...

SQL Server: Create Table using first row of Text File as Column names

Hello all, How can I read the first row of a text file (comma separated) and use that as the field names of a new table I want to create in SQL Server? The field names can all be varchar. Thanks all UPDTAE Please note I would like to do this using T-SQL or any other way (sqlcmd etc). I do not want to use the wizard. ...

how to make query in Oracle - like Access

hi In access I can make a query (1) that returns something and make another query (2) that uses the first query (1). How I can do it in Oracle 11g ? thanks in advance ...

Single SQL query on many to many relationship

I have a simple database with few tables (and some sample columns): Posts (ID, Title, Content) Categories (ID, Title) PostCategories (ID, ID_Post, ID_Category) Is there a way to create single SQL query which will return posts with categories that are assigned to each post? ...

If I drop a table and the table doesn't exist, I get an error.

Hi, I need to drop a table and make a new one. If I drop the table and the table doesn't exist, I get an error How can I check if the table exists? I'm working on Oracle 11g Thanks in advance. ...

Please Help Me With Mysql Slow Query Analysis.

I have this mysql query that I am trying to analyze. It is very slow, the visitor table here is about 50K entries, this query never returns. When I tried an explain statement, I found out that the index is not being used on the visitor table, In spite of the index being available. Now this is the great puzzle I need help solving. Any hin...

Criteria queries in JPA

Is there Hibernate criteria like queries in JPA? ...

Using alias in query and using it

I have a doubt and question regarding alias in sql. If i want to use the alias in same query can i use it. For eg: Consider Table name xyz with column a and b select (a/b) as temp , temp/5 from xyz Is this possible in some way ? ...

MySql query analyzer - free solutions

Hi, Is there a good (or not) Query Analyzer for MySQL (that's either free, or has a trial), than can analyze a query and make suggestions for indexes, like the "Display estimated execution plan" in Microsoft SQL Server management studio? Thank you, Frank ...

SQL Server: How does the type of an index affect a join's performance?

If I'm am trying to squeeze every last drop of performance out of a query what affect does having these types of index's being used by my joins. clustered index. non-clustered index. clustered or non-clustered index with extra columns that may not be involved in the join. Will I gain any performance if I go through and create cluster...

Lightweight query server

I'm looking for some service server that is extremely simple and lightweight. It's supposed to be used by administration scripts or simple apps to query for information that is available only as root on other server. I don't need high-throughput, stateful processing, etc. Only blocking, synchronous queries required. Preferably no HTTP s...

MS-Access Get price of product at certain order date

I have a table filled with purchase prices, like this: sku price btw startdate PCR-CA5425023181515 21,17 € 1 01/01/2009 PCR-CA5425023181515 999,00 € 1 06/06/2009 PCR-CA5425023181515 444,00 € 4 09/07/2009 PCR-CA5425023181515 100,00 € 4 10/08/2009 I have another table filled with orders, ...

Protecting system databases in Sql Server Management Studio?

For the five hundredth time, I ran a sql script in management studio to add some tables to a database and FORGOT TO CHANGE THE DATABASE IT RUNS AGAINST. Since it defaults to master, I had to go and drop all the new tables I just added. I practically never run sql scripts against the master database or other system databases, yet in Man...

bonuscode-system mysqlquery

Hello! I need your help for the following problem: These are my tables bonusCodes (called bc from now on) id code users maxinvoices maxusers activefrom activeuntil forfatter dato usedBonusCodes (called ubc from now on) id codeid (henviser til bonusCodes.id) fakturaid forfatter dato question what I want is the query to...

Data Binning with SQL or Linq

I am creating a custom reporting app in C# and need to aggregate some data. Let's make it simple. Say I have 10,000 sales for a year, I need a generic way to bin the data by say, month, day or hour. Each bin would therefore sum all the sales within that period. Has anyone ever written a query like this in either SQL or Linq? ...

MS Access 2003 - VBA for Parameter box that open after code is run: auto "ok"??

So there is a parameter box that open after a button click event runs an sql statement in vb for a list box to populate data. something like: me.listbox.rowsource = "SELECT tblMain.ID, TblMain.FirstName, TblMain.LastName, tblMain.MobileNumber FROM tblMain;" then i count the result for display like: me.recordcounter = me.listbox.listc...

Moving a value from one field to another in an SQL file

In my database I have a column named 'description' in this field There is an age at the beginning of the description ex: "Age 4+ This is a description for this row in the table". I created a column called 'age' and I have been trying to figure out a way to move the age from the description in one row to its corresponding age column. Ho...