query

linq query to populate DDL

I need immediate help. I have to create a class in asp.net 3.5. This class will take a dataset as input and have method in it that will populate dropdown list. The dataset has 5 columns. Based on column name passed as parameter to this method, the dropdown list will be populated with data in that column. Please add linq query to thi...

MySQL: Suggesting objects (optimizing a multi-join query)

Goal: Suggest objects based on user's choices Data: Table containing info on how users would order a subset of objects from the worst to the best; Example: 1 2 3 4 5 6 John: A B G J S O Mary: A C G L Joan: B C L J K Stan: G J C L There's about 20 times as many users as objects, every user's lineup contains 5...

MySQL Query - Getting distinct values

There is a table "T" that contains data as shown below: A B --------- 3 5 4 6 7 10 8 5 9 12 3 6 3 7 8 7 Assuming a given input set of {3,8} as values for A, how to retrieve all distinct values of B for which all values in the input set has an entry? B --- 5 7 EDIT: I think the question is not c...

How to get a particular attribute from XML element in SQL Server

I have something like the following XML in a column of a table: <?xml version="1.0" encoding="utf-8"?> <container> <param name="paramA" value="valueA" /> <param name="paramB" value="valueB" /> ... </container> I am trying to get the valueB part out of the XML via TSQL So far I am getting the right node, but now I can not figure...

Complex Sql Query Help. Forming query in SQL

Hello, I am new to SQL and need to write a complex query. Can you please help? I have two tables. One is called PATIENTS and the other one is called CASES. PATIENTS has a "patient number" and a date entered. CASES has "patient number," "case no." and "date modified." The two tables are connected with the "patient number." There are mul...

Sorting nearest date with MySQL

I have a simple task list which contains amongst others a title field and a deadline field. Some tasks got deadlines, other don't. Deadlines are simply stored with a MySQL date type. But the tough part (for me anyway) is to sort the tasks in the correct order: Ascending deadlines The rest (maybe by ID, but not important) Current que...

Doctrine: How to remove part of a where clause from select query inside listener (preDqlSelect)?

My listener is part of a behavior, that should remove all is_published checks in the where clause of any called select query. Adding a part to a clause is really easy, but how to remove one. There are some functions like Doctrine_Query->removeDqlQueryPart('where'), but that removes the complete where clause, while I only need the 'is_...

How to quickly duplicate rows in SQL

Edit: Im running SQL Server 2008 I have about 400,000 rows in my table. I would like to duplicate these rows until my table has 160 million rows or so. I have been using an statement like this: INSERT INTO [DB].[dbo].[Sales] ([TotalCost] ,[SalesAmount] ,[ETLLoadID] ,[LoadDate] ,[Up...

MySQL: Table Layout for perfomance (Multiple Query vs One single big query)

Hello stackoverflowers, I have a straightforward question. I am doing a web application that uses MySQL, and I am currently designing it. I just have a small question about performance. I would like to know what is more efficient: Scenario #1: Table: Restaurant -Name -City -Province -Country -Continent sql =...

C# Active Directory query results limit

I'm running a query on a container to determine how many objects it contains: DirectoryEntry entry = new DirectoryEntry("LDAP://CN=Users,DC=XXX,DC=YYY"); string filter = "(objectClass=Person)"; string[] properties = { "distinguishedName" }; DirectorySearcher search = new DirectorySearcher(entry, filter, properties, SearchScope.Subtree);...

How to limit fetching of entities from SQL query.

SQLQuery query = session.createSQLQuery("select {o.id} from order o " + "LEFT JOIN bookings b ON b.id = o.bookingId " + ); List pusList = query.addEntity(Order.class) .list(); and in order class I have: @OneToOne(cascade = CascadeType.ALL, mappedBy = "order", fetch = FetchType.LAZY) private Trip trip; but during exec...

Crossdomain bug in Flash player

I have just encountered an extremely odd behaviour from the Flash Player (10,0,32,18). I have a swf that tries to load data from a URL that contains a query. This works fine except for when the URL points at the root of the site. Flash Player then interprets the URL as a different domain and tries to load a crossdomain.xml file from the ...

How to query distinct values from map with given key in Hibernate?

I have following Hibernate 3 mapping for User class: <class name="org.test.User" table="users"> ... some other mapping... <map name="metadata" table="user_metadata"> <cache usage="transactional"/> <key column="user_id" not-null="true" foreign-key="FK_USERMETADATA_USER_ID"/> <map-key type="string" column="da...

SQL query against hardware. Possible?

I need to query the Total Physical Memory, Available Physical Memory and Total Commit Charge of the server. Basically values circled in the picture. Is it possible using SQL Server 2005? ...

Table of averages by date for multiple IDs

I have a table full of items that each have a unique ItemID. There is another table with information on tests that are done on these items around once a month (some may have multiple tests per month and some may have none some months) and each test entry has a full date mm/dd/yyyy. I would like to display the average of one of the fiel...

nhibernate named queries , name not found

I'm coming from a Java side of using Hibernate and I just haven't found the proper place to put the named query in NHibernate. Using Visual Studio 2008 , C# 2008 I have a query <query name="SchwabAccountList"> from DB_Accounts a where a.AdminOffCode = 'SWB' </query> and I want to put it in the .hbm.xml for the Account table (DB...

specific VB Linq Query help

I am still new to LINQ, and I have wrestled with a query for several days and am ready to surrender to ignorance on this one. I need to: join 3 tables (on a total of 2 databases). Lets call them Table1 Table2 Table3 Table1 joins to Table2 on "org" the result joins to Table3 on "emplid" Filters (where): Table3.success = true Table3...

Data structure to hold HQL or EJB QL

We need to produce a fairly complex dynamic query builder for retrieving reports on the fly. We're scratching our heads a little on what sort of data structure would be best. It's really nothing more than holding a list of selectParts, a list of fromParts, a list of where criteria, order by, group by, that sort of thing, for persistence...

sql server 2005 delete all table data in a set [DB].[audit].[tables]

So I have a database with around 100 audit tables and I want to empty them out preferably in 1 sql query. The database has 2 sets of tables [audit] and [dbo]. I'm not even sure what I should be calling these groups of tables so finding any kind of results from google is proving difficult. Any suggestions? ...

SQL Need a query that returns every field that contains a specified letter.

I have a SQL table with 11000 keywords in it. I want a query that can find fields which contain a certian letter. So if I include "a" and "b" the query will select all fields which contain the letter "a" and the letter "b" somewhere in the field. ...