query

Logging queries with Enterprise Library

I'm using Microsoft.Practices.EnterpriseLibrary.Data.Database to create my accessors and execute my queries. I'd like to know if there is anyway, within this scenario, to automatically log all queries and parameters that are being sent to the database. ...

[facebook] Query first_name, last_name, pic, from user and join with comment.

Hi! I would like to query user information like (first_name, last_name, pic, uid) then join with comments data such as text, time. first this is my query for comment SELECT text, time, username, fromid FROM comment WHERE post_id ='123456' then i need to join this query with user SELECT first_name, last_name FROM user WHERE **uid='...

Creating, Visualizing and Querying simple Data Structures

Simple and common tree like data structures Data Structure example Animated Cartoons have 4 extremities (arm, leg,limb..) Human have 4 ext. Insects have 6 ext. Arachnids have 6 ext. Animated Cartoons have 4 by extremity Human have 5 by ext. Insects have 1 by ext. Arachnids have 1 by ext. Some Kind of Implementation Level/Table0 ...

Is there an easier way to set a DateTime in SQL Server to be 23:59:59

Good Morning All, I'm trying to refactor an SQL stored procedure. I'm no SQL expert, but something tells me there must be a better way to do this. IF @ipv_dtEndDate IS NOT NULL BEGIN SET @ipv_dtEndDate = DATEADD(hh,23,@ipv_dtEndDate) SET @ipv_dtEndDate = DATEADD(mi,59,@ipv_dtEndDate) SET @ipv_dtEndDate = DAT...

sql query constructing formula

i have a table with two column: Name Values ---------------- Target 20 v1 10 v2 20 v3 10 Total 30 percent ? i want to calculate the percentage with the single column value to get the formula as --> Target/Total * 100. i.e for ex: Total = SUM (Values) in that way...... by using two rows in the colu...

LINQ Query to match a sequence

Hi, I have a result set, say clientList. And I want to make sure that ALL the clients in the ClientList have a Profession as "Banker". Let the result of the query be a boolean value. How can I write the LINQ or lambda expression query to get the result? ...

Lucene.Net IndexSearcher not working with BooleanQuery

I have the following code snippet: QueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new string[] { Field1, Field2, Field3 }, _analyzer); parser.SetDefaultOperator(QueryParser.Operator.AND); Query queryOrig= parser.Parse(queryString); var query = new BooleanQuery(); ...

PHP: What's the fastest way to query MySQL? Because PDO is painfully slow

I need to perform a simply query. Literally, all I need to perform is: SELECT price, sqft, zipcode FROM homes WHERE home_id = X When I use PHP PDO, which I've read is the recommended way to connect to a MySQL database, simply creating the connection takes a measured 610ms. My code is below: try { $conn_str = DB . ':host=' . DB...

LDAP or VBscript to list all real users in AD

Good morning all, Please can you help me with a LDAP query or VBscript to list all current users; real, flesh and blood people so it must exclude service accounts, administrator accounts and shared mailboxes. If you can help with this, it would be greatly appriciated. Kind regards, Justin ...

TSQL Finding duplicates

Finding Duplicate Row with Count Numbers Suppose a table is given ID Name Age ----------------- 1 Jon 30 2 Skeet 30 1 Jon 30 4 Gravell 30 5 NULL 30 4 Gravell 30 5 NULL 30 7 James 40 Required output (NULL also should comparable) ID Name Age Desc...

PHP & MYSQL : building a query based on multiple input values from users

Hypothetically I three tables: * recipes - contains recipes * ingredients - list of items * meals - list of meals I have a form that generates a selection like: Choose what ingredients you have: - apples - bananas - cherries Choose the meal this is for: - breakfast - lunch - dinner I want the user to be able to choose from either o...

Randomly Order Posts on WordPress Loop

Hi, I have the following code that shows 5 posts each being the latest from an author. Want I want to do is show the these 5 posts in a random order so that no author gets precedence over the other. To clarify this is the ordering of these 5 posts and NOT the posts of the author. Thanks code: <?PHP get_header(); ?> <script type...

How to get all details about version, SP of SQL Server 2005

Hi All, I want to find the version, SP applied (CU if any) applied on SQL server. I am able to get verison no. using @@VERSION. But I want the whole list of patches/SP applied to it. Can you please help me out. Thanks, Sunil ...

How to fetch the nth highest salary from a table without using TOP and sub-query ?

Hi, Recently in an interview I was asked to write a query where I had to fetch nth highest salary from a table without using TOP and any sub-query ? I got totally confused as the only way I knew to implement it uses both TOP and sub-query. Kindly provide its solution. Thanks in advance. ...

some query statement not working with db_query(Drupal)

Why does some query that works in mysql doesn't work with db_query? For instance - " SELECT * FROM {tb1},{tb2}WHERE {tb1}.vid=%d " (Of course I substitute %d with actual vid value while I'm testing in mysql environment) "SELECT f1,f2,...,f10 FROM {tb1} INNER JOIN {tb2} ON {tb1}.vid = {tb2}.vid WHERE {tb1}.vid = %d AND {tb2}.vid = %d A...

How can I use an alias inside a sub-query?

What I am trying to achieve is to get the rows having the maximum value from a table of the following form: A | B | Ratio 0 | 1 | 1.0 1 | 2 | 1.0 2 | 3 | 1.0 3 | 4 | 0.33 4 | 5 | 0.25 I am trying to display only rows containing the maximum value (in this case 1.0). May be I am not doing this right. I have a query of the form: SELECT...

How can I SELECT+INSERT in the same mysql query?

I have a php script that process keywords from a mysql table "keywords" (columns: id - keyword) and then it saves data into another table "data" (column: id[foreign key keywords.id] - dataname - datavalue). My problem is that when the script is ready to save the data I only have the keyword and not the id. So is there a way I can get t...

How to optimize a 'col = col + 1' UPDATE query that runs on 100,000+ records?

See this previous question for some background. I'm trying to renumber a corrupted MPTT tree using SQL. The script is working fine logically, it is just much too slow. I repeatedly need to execute these two queries: UPDATE `tree` SET `rght` = `rght` + 2 WHERE `rght` > currentLeft; UPDATE `tree` SET `lft` = `lft` + 2 WHERE `lft...

SQL - exclude a column from SELECT query

I have 100 columns in a table, i want to list 99 columns except a particular one, how to exclude that columns name? ...

php MySql QUERY for Friends relations Table help

EDIT by:lawrence. I got the right query now select * from users, friends where (users.id=friends.user_id1 and friends.user_id2=$profileID) or (users.id=friends.user_id2 and friends.user_id1=$profileID) Question answered I need some help joining results from my friends and users table This is what my friends table look lik...