query

Displaying data from DataReader in Label control (ASP.NET)

Hey, I have a query that returns one row so I want to display it in the Label, but I can't find the property DataSource on it. How can I do this ? ...

How to optimize this MySQL query

This query was working fine when the database was small, but now that there are millions of rows in the database, I am realizing I should have looked at optimizing this earlier. It is looking at over 600,000 rows and is Using where; Using temporary; Using filesort (which leads to an execution time of 5-10 seconds). It is using an index...

Least intensive way to find all nested subcategories using mysql query

I have a database in which items are placed into categories. Some of these categories are nested, so as an example: Animals > Birds > Parrots Animals > Birds > Penguin Animals > Mammals > Cats Animals > Mammals > Dogs Animals > Reptiles > Snakes Plants > Trees Plants > Flowers etc I have these in a table along the lines of ...

Count the frequency of votes in MySQL

I am making a website where users can vote on which category a page is. They can vote that the page is in category a, b, c, or d. I need to find the most commonly occurring category in the MySQL row out of all the votes. Each time a user submits their vote, it submits the "category" that they voted for, and the "page_id". I have thi...

Oracle : select maximum value from different columns of the same row

The whole question is pretty much in the title. For each row of the table I'd like to select the maximum of a subset of columns. For example, from this table name m1 m2 m3 m4 A 1 2 3 4 B 6 3 4 5 C 1 5 2 1 the result would be name max A 4 B 6 C 5 The query must be compatible oracle 8i. Thanks. ...

problem in counting two fields in one query

hey guys i need to count new private messages and old one from a table so first thing come to mind is using mysql_num_rows and easy thing to do // check new pms $user_id = $userinfo['user_id']; $sql = "SELECT author_id FROM bb3privmsgs_to WHERE user_id='$user_id' AND (pm_new='1' OR pm_unread='1')"; $result = $db->sql_qu...

Doctrine/symfony: getSqlQuery() output in phpMyAdmin/SQL tab

Hi, i have created this query that works OK: $q1 = Doctrine_Query::create() ->from('Usuario u') ->leftJoin('u.AmigoUsuario a ON u.id = a.user2_id OR u.id = a.user1_id') ->where("a.user2_id = ? OR a.user1_id = ?", array($id,$id)) ->andWhere("u.id <> ?", $id) ->andWhere("a.estado LIKE ?", 1); echo $q1->getSqlQue...

Access Qry Questions

It was suggested that I repost this questions as I didn't do a very good job discribing my issue the first time. (http://stackoverflow.com/questions/2921286/access-question) THE SITUATION: I have inspections from many months of many years. Sometimes there is more than one inspection in a month, sometimes there is no inspection. However...

exploratory SPARQL queries?

whenever i start using sql i tend to throw a couple of exploratory statements at the database in order to understand what is avaliable, and what form the data takes. eg. show tables describe table select * from table could anyone help me understand the way to complete a similar exploration of an rdf datastore using a SPARQL endpoin...

How to detect a SQL Server database's read only status using tsql

I need to know how to interrogate my Microsoft SQL Server to know if a given database has been set to read only or not. Is that possible? ...

Which of these queries is more efficient?

Which of these queries are more efficient? select 1 as newAndClosed from sysibm.sysdummy1 where exists ( select 1 from items where new = 1 ) and not exists ( select 1 from status where open = 1 ) select 1 as newAndClosed ...

WordPress: Prevent Showing of Sub Category Posts

Hi, I'd like to know how to prevent showing of sub-category posts. My home page lists all posts from three "main categories" (parent category), but unfortunately it's also listing some posts from the sub-categories. Here's the code that I'm using to get the posts from specific category: <h2>Category Name</h2> <ul> <?php $category_...

How UPDATE and SELECT at the same time

I need to update some rows of the tables and then display these rows. Is there a way to do this with one single query and avoid this 2 query ? : UPDATE table SET foo=1 WHERE boo=2 SELECT * from table WHERE ( foo=1 ) AND ( boo=2 ) ...

Join query in MySQL cursor

We can declare a cursor like this DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1; Can we use a join query instead of a simple query? ...

Avoiding secondary selects or joins with Hibernate Criteria or HQL query

I am having trouble optimizing Hibernate queries to avoid performing joins or secondary selects. When a Hibernate query is performed (criteria or hql), such as the following: return getSession().createQuery(("from GiftCard as card where card.recipientNotificationRequested=1").list(); ... and the where clause examines properties that ...

sql query by passing te values in one table

can any one help me in generating query for the below scenario? i have twop tables TableA and TableB TableA has teh follwing columns EMPLOYEEID, SKILLSETCODE,CERTID, LASTNAME, FIRSTNAME, MIDDLEINITIAL TableB has two columns EMPLOYEEID and key_user i want to SELECT EMPLOYEEID, SKILLSETCODE,CERTID, LASTNAME, FIRSTNAME, MIDDLEINITIAL ...

PHP mySQL query's and PHP Variables

I'm trying to make an OO Login system for a project I'm working on, and am having trouble with inserting variables into the query strings. In the code below, if I replace "$TBL_NAME" with the actual table name it works. Why isn't $TBL_NAME translating to the value of $TBL_NAME? class UserDB { private $TBL_NAME = "users"; public ...

Passing Multiple values Through Query String?

Hi all, I tried to pass more than one value through Query String from page1.aspx to page2.aspx. This is my Query string in the Grid View <a href="javascript:void(0);" onclick='javascript:window.open("Update.aspx?Regno= <%#Eval ("ID") %>'+ ","'&Fn=<%#Eval ("FIRSTNAME") %>' +", "'&Ln=<%#Eval ("LASTNAME") %>'")';> Edi...

converting linq query to icollection

Hi there. I need to take the results of a query: var query = from m in db.SoilSamplingSubJobs where m.order_id == id select m; and prepare as an ICollection so that I can have something like ICollection<SoilSamplingSubJob> subjobs at the moment I create a list, which isnt appropriate to my needs: query.ToList(); what do I do...

Find objects between two dates MongoDB

I've been playing around storing tweets inside mongodb, each object looks like this: { "_id" : ObjectId("4c02c58de500fe1be1000005"), "contributors" : null, "text" : "Hello world", "user" : { "following" : null, "followers_count" : 5, "utc_offset" : null, "location" : "", "profile_text_color" : "000000", "friends_...