query

SQL SELECT distinct rows from a table by multiple columns ignoring columns order (significance)

I have a table People (First_Name, Last_Name). This table has records that are duplicated as in the example (not all rows are duplicated): First_Name Last_Name John Smith Alec Baldwin Smith John Angelo Gordon Mary Bush Bush Mary How do I select all distinct people? In the final output of the que...

Firebird and Table,field name lowercase

I have converted a database from MySQL to Firebird, all tables name and field name are in lowercase, when i query the database, give me an error of table not found because firebird convert automatically the name of table in the Query in UPPERCASE letter, but my table name in database is lowercase. For query the database i'm obliged to e...

JPA: caching queries

Hi! I'm using JPA to load and persist entities in my JEE-based web application. Hibernate is used as an implementation of JPA, but I don't use Hibernate-specific features and only work with pure JPA. Here is some DAO class, notice getOrders method: class OrderDao { EntityManager em; List getOrders(Long customerId) { Query q =...

TSQL: Get Last Queries Ran

Is there a way to get the SQL text for the last few queries? I am using Microsoft SQL Server 2005 ...

Linq To Sql / SQL Query Help

I have a table that looks like this: Id PageId Key Content LastUpdated --------------------------------------------- 1 12 key1 content1 02-21-2010 2 12 key1 content2 02-25-2010 3 12 key2 content1 02-21-2010 4 12 key2 content2 02-25-2010 5 12 key3 ...

One to Many Linq to XML query

Hi, I have an XML string that looks like this: <Attributes> <ProductAttribute id="1"> <ProductAttributeValue> <Value>a</Value> </ProductAttributeValue> </ProductAttribute> <ProductAttribute id="2"> <ProductAttributeValue> <Value>a</Value> </ProductAttributeValue> ...

update null for type date

I have a sentence follow: string strSQL = "update pl_poli set ag_vouch = ' ',ag_vdate = #, ag_vmode = null where pl_no = '" + textBox5.Text + "' and pl_endtno ='" + textBox6.Text + "'"; I can't update because error "data type mismath". i have fill ag_vdate is type date I want to Update it -> null Please can you help me. Thank you...

Cascade Delete Query

I have three tables. Product, Company, Employee ProductId of Product table is foregin key for Company and CompanyId of Company table is foregin key for Employee So on deleting ProductId from Product table, all the related records in other tables should delete. But I can't touch schema(can't use alter table). How should I write the que...

How to Add a Third Table in an SQL Query Containing a SUM

I have the following SQL Query: SELECT porel.refcode, podetail.ponum, SUM(podetail.orderqty * podetail.unitcost) AS Total FROM podetail LEFT JOIN porel ON podetail.ponum = porel.ponum WHERE porel.poline=podetail.poline AND porel.reftype = 'SPEX' GROUP BY porel.refcode, podetail.ponum ORDER BY porel.refcode, podetail.ponum which works ...

SQL Server Comma Separated value among columns

I want to select columns as comma-separated values by doing something like: select column1+','+column2+','+column3+','+coulmn4 from someTable except if any of the columns hold null values i have to skip that column from adding comma how to do this is SQL Server? [All columns are of type varchar so no casting needed] ...

mysql simple aggregate of subquery results is slow

I'm trying to 'bin' all of my customers based on the number of items purchased, and display the counts of each bin. I'm trying to see how many people(account_id) purchased one item, how many purchased two items, all the way through nine items, and then ten or more. Here's the query I'm using - for what its worth, I'd expect the query t...

Group Query with Calculations on Rails 3

Rails 3 problem. I have a Foods table of foods with the following attributes: name calories (per gram) fat (per gram) carbs (per gram) protein (per gram) I then have a LoggedFoods table representing a food that has been eaten at a given time. It has the following attributes: food_id number_of_grams_eaten ate_when (datetime) So th...

managedQuery always returns the same result

In my onItemClick method I have: public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Uri formula = ContentUris.withAppendedId(Formulas.CONTENT_URI, id); Cursor formulaCursor = managedQuery(formula, PROJECTION, null, null, null); formulaCursor.moveToFirst(); searchBar.setText(formulaCursor...

[jquery ajax] NS_ERROR_ILLEGAL_VALUE when setting an authorization header

Hi, I'm currently messing around with google APIS. My code consist of 2 request : One for the authentification (using clientLogin). Another to interact with the service from which i need the data. Actually i'm stuck before executing the second request. I'm trying to set an header value to the token value received from the first request...

Wildcard not working in SQLite

I keep trying to use wildcards in a search in an android app, and keep running into errors. I'm performing a search on my application using the string below: Cursor c_name = b.query("namedrxns", new String[] { "_id", "name" }, "name LIKE %?%", new String[] { query }, null, null, null); when I use name LIKE %?% or name=...

MySQL: how would I go about displaying simple "categories" for this?

I'm wishing for a simple index more or less with my PHP note taking software, each note has a "language" field for the programming language its written in. When I iterate through each entry in a while loop, I'm not sure how i'd list categories of them such as: PHP: Note 1 Note 5 SQL: Note 2 Note 3 Do I need to place all entri...

Debug/visualize database query internal mechanism

I wonder if some open-source SQL database servers have a possibility, how to find out (maybe even in graphical representation), what actually happened inside during the query (e.g. whether table scan was used, or if and which index(es) were used..) step-by-step. It would be useful for database optimization. ...

How we can assign a value in mysql query

Hi How we can assign a value in the querywhat i need is assume that i write a query for output result using match against i am getting a bunch of result like http://www.flipkart.com/account.php http://www.thomas.com/account.phphttp://www.flipkart.com/account22.phphttp://www.flipkart.com/account45.phphttp://www.thomas.com/account22.phpht...

mysql select query

My question is very simple, but I can't seem to find the answer on here. So, All I want to do is select from two tables at once (with identical column names[id]) I currently have "SELECT * FROM table1 WHERE id='$id_var'" but I also need to check 'table2' aswell. What's the best way to do this without creating a second query? th...

Linking category posts (Wordpress)

I have a category in Wordpress called News and would like to link to the next news page when viewing a story. This is the existing code but will link to all posts, what should I add to make it just posts in the News category? <div id="page-navi"> <div class="button previous"><?php previous_post_link('%link') ?></div> <div class="butto...