query

hibernate how to retrieve a hierarchy object

Hi all, I have the following beans Task, ServerDetails and ApplicationDetails. I wish to retrieve all tasks, their server details and application details based on a specific application name. From the result i expect to be able to retrieve the data in a manner such as: task.getServers().getApplicationDetails() In actuality, I get wha...

Query a dataTable by large Query String

I have a datatable that i want to query. the query is very large and complicated and it works when i run it in the SQl Server Editor - so i have the query text. i need to query the datatable with this query String. To Translate the query into linq will take years, and also Select() method of DataTable won't handle it. How can i operate...

LinQ query - Add Where dynamically

I am having a hard time solving this problem, need code for creating a dynamic linq query in C#, asp.net. I have 5 dropdown list that searches different column in same database table and return item filtered value to a single listbox. The problem is there is no sequence that which or all or any wil be selected in DDLs but the combined...

SQL complex query

Hi, I have two tables: 'Category' and 'Product'. In Category I have catid and cat name. In product table I have item-id, item-name, catid. What I need to do is show a result that will have item name and category name. But the category name will be multiple. So that one product can have multiple categories on it. ...

How TO join many tables into one in Access

Hi, I had a table with some 25000 records and 75 fields. For easier analysis i broke them down into 10 tables with 2500 records each. now i want to put them back together to form a single table. how do i write a query. i tried a select query like select * from (table1, table2.....) but i get error as query is too complex. tksy ...

help! Linq query

I am getting error msg on the word Records - Type or namespace could not be found. Please help debugging it, what is missing? if (ProjDDL1.SelectedItem.Value != "--") results = CustomSearch<Records>(results, s => s.Business == ProjDDL1.SelectedItem.Value); Method CustomSearch: private DataTable CustomSearch<TKEY>(DataTable dt, Fun...

Help in optimizing a query for a Postgresql database

I'm trying to find some suggestions in optimizing a query that I'm using to fetch a large group of data. The original code that I'm working on looped through a large set of users, and calculated a date range for each one of them. It would then take that date range and query how many questions they answered and how many they got correct...

Nhibernate N+1 query problem

I need help with NHibernate. I'm using 2.1, but have tried this on 3 as well, with same results. Any help most appreciated! When doing an ICriteria query using NHibernate, it executes both the query, and then for each result in the query, it executes another query to select an associated object, which is already returned in the initial ...

how to run on 4 tables and make update any field on them ? - oracle 10g

hi how to rum on 4 tables and update any field on them ? in oracle 10g thank's in advance ...

MS ACCESS How to drop a column with primary key.

I want to drop a column from table in access which is the primary key. how can i write a query for this. ...

Help with MySQL Query with many Joins

Setup: Contact database using 4 tables Contacts Cities States Zips Structure: CREATE TABLE `contacts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `last` varchar(100) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL, `first` varchar(100) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL, `prefix` varchar(50) ...

SQL query generator for Perl with stored procedures support

Current code base I'm working on is full of ad-hoc conditional string concatenations producing less than clear SQL queries. I want to make them maintainable, but since using DBIx::Class is too complex to move to for now (giant legacy base), I'm looking to at least make them more robust by using some sort of SQL generator, which would onl...

Getting related tags from SQL Server when you have filtered down

I asked this question before and got a great working answer. http://stackoverflow.com/questions/1648190/what-is-the-query-to-get-related-tags-like-in-stack-overflow but i realized that SOF actually takes it one step further as it supports multiple tag drilldown what i mean is, if click on the tag C#, that will filter to 20,000 questi...

How to delete duplicate rows in SQL Server 2008 ?

hi how can I delete duplicate rows in SQL Server 2008 ? thanks in advance ...

Most efficient way to query the newest 20 posts per category on the sme page

I am using PHP and mySQL. I have a table of photographs. in the photographs table I have: a link to the photo, a category_id, date. What would be the best way to list all the categories on the page with the newest 20 photos under each? Right now I am selecting all the photos and then sorting them out after in PHP. If there gets to be 5...

php mysql query syntax question regarding ""'s

Forgive me, I'm a beginner. The following code returns a parse error: $query = "INSERT INTO scenario_needgames VALUES ("$id", "Battle of the Bulge")"; the query builder in phpMyAdmin gave me this slightly modified string that works: $query = "INSERT INTO scenario_needgames VALUES (\"$id\" , \"Battle of the Bulge\");"; but I'm confu...

is there an equivalent of the "IN" function for adding "AND"s to queries

i have the following tables in sql server: photoalbumsTable: album_ID album_caption albumtagmap id album_id tag_id albumtags id tag_name i have the following query which will show me where t.tag_name is in "Trips" OR 'Beach": SELECT b.* FROM albumtagmap bt, photoalbums b, albumtags t WHERE bt.tag_id = t.id...

Complicated MySQL Query For Wordpress

Sometimes I think I haven't got the brain power for programming, I just can't get my head round this. I've got a table called wp_postmeta which looks kind of like this +-----------+-----------+------------+--------------+ | meta_id | post_id | meta_key | meta_value | +-----------+-----------+------------+--------------+ | 1 ...

Query to pull sum from 2 different tables, is this possible in one query?

Thanks for all the help so far, now I just ran into a major problem! I have 2 tables that contains daily commissions, and for each day, I have to SUM the daily totals from each table. Daily limit is maxed at $100, so anything over $100 for the day is $100. Employee (employeeID INT PK, totalCommisions INT ) Now the 2 tables that conta...

Deleting similar columns in SQL

In PostgreSQL 8.3, let's say I have a table called widgets with the following: id | type | count -------------------- 1 | A | 21 2 | A | 29 3 | C | 4 4 | B | 1 5 | C | 4 6 | C | 3 7 | B | 14 I want to remove duplicates based upon the type column, leaving only those with the...