query

Setup MySQL query timeout

Hey guys, it's possible to timeout query in MySQL? So if any query will exceed this timeout, it will be killed by MySQL and it will return error instead of waiting for eternity. ...

sorting with 3 categories

so here's the problem I have 3 types for a hotel premium featured basic I am trying to display a list of hotels and sort them so that featured hotels are the first shown what mysql query would accomplish this? EDIT here's the table, with some fields stripped ID | hotel_name | type ======================= 1 | Aria Hotel | basic ...

SQL [CASE Query View]

SELECT DT, FlowParam, Abs_P, T, Volume, Energy, FlowTime_T, (SELECT ' > 1 ' AS Expr1 WHERE ( (SELECT COUNT(*) AS Expr2 FROM dbo.BACS_Alarm_1 WHERE (DT_T >= dbo.BACS_HourFlow_1.DT_T) AND (DT_T <= dbo.BACS_HourFlow_1.DT_T + dbo.BACS_HourFlow_1.FlowTime_T) ) > 1 )) AS...

The result of stored procedure to a table, without creating the table manually in SQL Server

What I need to do is, put the results of stored procedure (with lots of parameters) in to a table. Something like that: SELECT * INTO Table_1 FROM ( EXEC [MY_DataBase].[dbo].[GET_Report] '%%', '%%', '%%', 'x', 'x', 'x', 'x', 'x', 'x' .... ) X However this seems to be an incorrect syntax, I searched for it and people are first creatin...

Tips and Tricks about query optimization [SQL Server 2005]

I am asking this question in stackoverflow because its the right place to ask... I know its a very vast topic to start but some small ones which may be really handy... It might be useful for young developers like me to know about query optimization.. Some Tips and Tricks about query optimization in SQL Server 2005.. ...

Database queries in Java

How can I connect to MySQL db and execute queries ? ...

SQL View. Select count... Where...

I am most confused with this one, so i d better ask the experts! These are the rows returned by a custom query of mine. Col1 Col2 Result Font Bold a Font Bold b Font Bold a Font Italic a Is there any way of using selecting count in the above (table) results in order getting this one? Col1 Col2 ResultA ResultB ...

Java/Hibernate: how to write DAO code for complex SQLs

Hi all, My current workplace uses the standard Spring/Hibernate/JSP mix to serve content to its Flex client via XML. There are many ways in which the data is accessed, but the most prevalent one is via direct SQL calls to the database and a manual conversion to XML. The trouble is that as the application grew bigger, the SQLs became mu...

aspx vb.net checkboxlist to be populated from sql server

can you populate checkboxlist from sql server query like a dropdownlist? with autopostback=true? i am using vb.net and have 50 checkboxes that shall show up from the database data depending on the selected value of the previous dropdownlist. also can i change the label of the checkbox each time the value is from DB? the label shall be sa...

Storing multiple values in a single cell in MySQL

I'm storing multiple numbers in a MySQL cell by using a delimiter (eg "1,5,10") and the TEXT datatype. How do I perform lookups like this? SELECT * FROM MyTable WHERE MultiVals CONTAINS "5" And lastly, is this the preferred approach to store such values? I'm using this like a linker table, to link certain rows to multiple other rows ...

Which is the best for this query, "Inner join" or "Where"

I have this query, our friend "OMG Ponies" help me to make it :) :- SELECT t.id AS taskid, STUFF( ( SELECT ',' + x.tID FROM ( SELECT CAST(id AS VARCHAR(200)) AS tid FROM CRSTask c WHERE c.ParentTask = 7562 -...

iphone:creating a query

hi all, in my table of sqlite database, there are fields named id,firstName,middle, lastName now i want to run the query as following MyQuery = [NSString stringWithFormat:@"select id,(firstName || middlename || lastname) as Name from Students where firstname like '%@' or middlename like '%@' or lastname like '%@'",searchBarString,sear...

SQL Query taking forever

Hi, I have this webapplication tool which queries over data and shows it in a grid. Now a lot of people use it so it has to be quite performant. The thing is, I needed to add a couple of extra fields through joins and now it takes forever for the query to run. If I in sql server run the following query: select top 100 * from bam_Pr...

Joins with multiple fields on GroupBy table data in LINQ query/method

Urgent: I have to work out how to write the following SQL query usingLINQ query or method syntax. (Edit: This is to return a list of latest AgentActivities for all Agents). Any help will be much appreciated. SELECT a.[AgentActivityId], a.[AgentId], a.[ActivityId], a.[StartedAt], a.[EndedAt], a.[Version] FROM [dbo].[AgentActivity...

Linq to SQL query taking forever

Ok, first I thought I had a problem with how I was querying things. But apparently the problem lies in how linq translates my query to sql. Here's my linq: var items = (from p in ctx.bam_Prestatie_AllInstances join q in ctx.bam_Zending_AllRelationships on p.ActivityID equals q.ReferenceData join r in ctx.bam_Z...

How to fetch users by rating with mysql query? (Top Rated)

There is a query I've just made SELECT * FROM users INNER JOIN ratings ON ratings.rateable=users.id ORDER BY SUM(ratings.rating)/COUNT(ratings.rating) But, it doesn't work, I just get one person in result, although there are 3 people in ratings table! I'm using php 5. I think sum(), count() doesn't work at all! Please,...

array_intersect_key PHP array with MYSQL database

I have a simple array in PHP, say [1, 2, 4, 5, 6, 7] and I wish to query a MYSQL database [1, who] [2, where] [3, some] [6, there] [9, too] I only wish to receive the rows of intersection between the PHP array and the database's indices column. So this would result in [1, who] [2, where] [6, there] Any ideas? Thanks! ...

Fatal error: Maximum execution time of 60 seconds exceeded in \doctrine\lib\Doctrine\Collection.php on line 462

Whats this?? my query is: Doctrine_Query::create() ->select('rec.*') ->from('Records rec') ->execute(); Records table contains more than 20k rows. On executing query on page i am getting an error: Fatal error: Maximum execution time of 60 seconds exceeded in...

How can get unique values from data table using dql?

I am having a table in which there is a column in which various values are stored.i want to retrieve unique values from that table using dql. Doctrine_Query::create() ->select('rec.school') ->from('Records rec') ->where("rec.city='$city' ") ...

How to set a variable in Wordpress's $wp_query

I'm trying to use the set() function, to set $wp_query->query_vars['paged']. What's the proper syntax for this function? Thanks. ...