query

i want Oracle Query for Formatted Output

Following is my table deign Ecode Degree YOQ 7654321 SSC 2000 7654321 HSC 2002 7654321 Bcom 2006 7654321 MCA 2010 7654322 SSC 2002 7654322 HSC 2004 7654322 Bcom ...

JPA - FindByExample

Does anyone have a good example for how to do a findByExample in JPA that will work within a generic DAO via reflection for any entity type? I know I can do it via my provider (Hibernate), but I don't want to break with neutrality... Seems like the criteria API might be the way to go....but I am not sure how to handle the reflection p...

How do I create queries to SQL Server tables via Visual Studio when no knowledge about SQL nor Linq?

Let´s be frank, my knowledge regarding SQL language is very low. Nevertheless, my boss gave me the task to build a database application using the following tools: SQL Server and Visual Studio 2008; C#. I use the VS DataSet as a local mirror of the SQL Server. And let´s be frank again, my understanding of the VS Query builder is also ve...

NHibernate query with Projections.Cast to DateTime

I'm experimenting with using a string for storing different kind of data types in a database. When I do queries I need to cast the strings to the right type in the query itself. I'm using .Net with NHibernate, and was glad to learn that there exists functionality for this. For the example I'm using this simple class: public class Foo...

Need help with a SQL CTE Query

I have a table that I need to get some specific data from for a view. Here's the base table structure with some sample data: | UserID | ReportsToUserID | Org ID | ------------------------------------- | 1 | NULL | 1 | ------------------------------------- | 2 | 1 | 1 | -----------------------...

MySQL TEXT field performance

I have several TEXT and/or MEDIUMTEXT fields in each of our 1000 MySQL tables. I now know that TEXT fields are written to disk rather than in memory when queried. Is that also true even if that field is not called in the query? For example, if I have a table (tbExam) with 2 fields (id int(11) and comment text) and I run SELECT id FROM...

T-SQL Question - Counting and Average

I have a set of data that consists of a filenbr, open date and close date. I need to produce a summary table similar to the below, i need to count how many files belong to each day period, but i need those greater than 20 grouped together. I know how to get the datediff, what i'm stumbling on is how to get the 20+ and the % column 1 d...

App engine JPA date query

Hi There. Assume I have object which represents TASK. Task have due date. How do I create query to get all tasks which are due today? Some working code like "select t from Task t where dueDate=:today" will be usefull. Thank you in advance. ...

MySQL: Data query from multiple tables with views

I want to create a query result page for a simple search, and i don't know , should i use views in my db, would it be better if i would write a query into my code with the same syntax like i would create my view. What is the better solution for merging 7 tables, when i want to build a search module for my site witch has lots of users an...

SQL concatenate rows query

Say we have a table table posts +---------+-----------+--------------------------------+ | postId | title | status | bodyText | +---------+-----------+--------------------------------+ | 1 | Hello! | deleted | A deleted post! | | 2 | Hello 2! | deleted | Another one! | | 3 | New 1 ...

Is using joins in select clause slow in Oracle?

I would like to write a query like the following select username, (select state from addresses where addresses.username = users.username) email from users This works in Oracle (assuming the result from the inner query is unique). However, is there a performance penalty associated with this style of writing query? ...

PHP: MySQL query duplicating update for no reason

The code below is first the client code, then the class file. For some reason the 'deductTokens()' method is calling twice, thus charging an account double. I've been programming all night, so I may just need a second pair of eyes: if ($action == 'place_order') { if ($_REQUEST['unlimited'] == 200) { $license = 'extend...

Access is refusing to run an query with linked table?

Hey all i have 3 tables each as follow cash_credit Bank_Name-------in_date-------Com_Id---Amount America Bank 15/05/2010 1 200 HSBC 17/05/2010 3 500 Cheque_credit Bank_Name-----Cheque_Number-----in_date-------Com_Id---Amount America Bank 74835435-5435 15/05/2010 2 600 HSBC ...

Error using to_char // to_timestamp

Hello, I have a database in PostgreSQL and I'm developing an application in PHP using this database. The problem is that when I execute the following query I get a nice result in phpPgAdmin but in my PHP application I get an error. The query: SELECT t.t_name, t.t_firstname FROM teachers AS t WHERE t.id_teacher IN ( SE...

PostgreSQL equivalent to "SET SESSION query_cache_type = ON/OFF";

I just wanted to know what's the equivalent query in PostgreSQL to MySQL's SET SESSION query_cache_type = ON SET SESSION query_cache_type = OFF ...

PHP echo query result in Class??

Hi all I have a question about PHP Class. I am trying to get the result from Mysql via PHP. I would like to know if the best practice is to display the result inside the Class or store the result and handle it in html. For example, display result inside the Class class Schedule { public $currentWeek; functio...

How would I UPDATE these table entries with SQL and PHP?

I am working on an Asset Database problem. I enter assets into a database. Every object is an asset and has variables within the asset table. An object is also a type of asset. In this example the type is server. Here is the Query to retrieve all necessary data: SELECT asset.id ,asset.company ,asset.location ,asset.purchaseDate ,...

mysql query help, take total sum from a table, and based on discount value on another table calculate the gross_total

hi I have a table called invoices: `si_invoices` ( `id` int(10) , `biller_id` int(10) , `customer_id` int(10) , `type_id` int(10) , `inv_tax_id` int(10) , `date` date , `unreg_customer` tinyint(1) , `discount` decimal(10,2) , `discount_type` tinyint(1) ) each invoice has items that are stored in invoice_items tabl...

help with query

How to list the departments in Oracle's EMP table which have either two clerks or three managers? ...

Why is postgresql update query so slow sometimes, even with index

i have a simple update query (foo column type is BOOLEAN (default false)): update tablename set foo = true where id = 234; which "id" is set to (primary) key, and if i run "explain analyze" i got: Index Cond: (id = 234) Total runtime: 0.358 ms but still, i have plenty of unexplained queries at slow log (pgfouine), which took more t...