query

Count parents backwords in one SQL Query?

I have a MySQL database (created by Wordpress) and this is similar to what it looks like: ID parentID otherStuff 54 55 this is a test 55 56 another test 56 0 last test What I need to do is to check how deep down a page is. I know that when it reaches parentID 0 it's finished. I could wri...

Why is this MySQL UPDATE taking forever?

I'm trying to figure out why one of our migration scripts is taking forever we are trying to do an update that joins from another table to get a relevant piece of data. Each table (A, B) has about 100,000 rows. # now populate the ACHIEVEMENT_INSTANCE.OBJECTIVE_INSTANCE_ID update A a, B b set a.INSTANCE_ID = b.INSTANCE_ID where a.ID = b...

How do you consistently retrieve the path information from the query in php? (/index.php/foo/bar)

Basically if the user requests: index.php/foo/bar I need "/foo/bar" and for index.php I need "" or "/" I couldn't find any information on google because I don't know what this is called (path info got me the pathinfo() function) I found PHP_SELF returns differently if there is path info than if there is no info ...

Mysql SELECT nested query, very complicated?

Okay, first following are my tables: Table house: id | items_id | 1 | 1,5,10,20 | Table items: id | room_name | refer 1 | kitchen | 3 5 | room1 | 10 Table kitchen: id | detail_name | refer 3 | spoon | 4 5 | fork | 10 Table spoon: id | name | color | price | quantity_available | 4 | spoon_a | white | 50 | 100...

What should be the best way to load setting from Database?

Hello, how should i load the table "Setting" into an asp.net mvc so that i can use it as a reference setting for the whole application. Is there anyway to save the memory and usage to do this problem? In my understanding, if i have settings in database, i will have to make the program load the table into a variable, then call out. But i...

Help in writing Query for hall booking date availability search

I need help in writing query to find the time slot availability for a hall booking system.. details are given below I have a Hall table which stores the hall details and HallBooking table which stores the start and from time of the bookings done.. Hall - HallId - Name HallBooking - HallBookingId - HallId - BookingPersonName - StartDat...

Find Most Recent Entry for an Intersection of Categories

I know there are a number of "How do I find the most recent record" questions out there, but none of them quite solved my particular problem: in MySQL, I'm trying to find the most recent record for an entry that's mapped to two different categories in the same table. There's essentially an ENTRIES table with a bunch of info, a CATEGORIES...

Substitute MySQL result

I'm getting the following data from a MySQL database +----------------+------------+---------------------+----------+ | account_number | total_paid | doc_date | doc_type | +----------------+------------+---------------------+----------+ | 18 | 54.0700 | 2009-10-22 02:37:09 | IN | | ...

One query at a time on a SharePoint list

I have a small application that uses a SharePoint list as the data source. This application has to be used by many users at the same time. There may occur a situation when more than one user woult want to edit the same list item of the SharePoint list. And that's not the way the application is intended to work. I need to modify the way ...

.NET - SQL Select --> Array. What is the fastest way?

I'm using VB.NET. I am performing a select query that returns approximately 2500 rows, each containing 7 fields. I am using a SqlDataAdapater and filling a dataset with the single table returned by the Select query (from the local database). (I only perform the data-retrieval once (see below) and I don't even start the StopWatch until...

Projection of dis-joint sets in LINQ

I have two string arrays ( I will not use it anywhere as it is not a good logic,this is for my learning purpose). string[] names = new[] { "Joss", "Moss", "Kepler" }; string[] emails = new[] { "Moss@gmail", "Kepler@gmail", "Joss@gmail" }; How to use LINQ so as to make key value pairs like {"Joss","Joss@gmail"} ,{"Moss","Moss@gmail"...

Is there an application for displaying some kind of query plan for a Linq to object query?

I'm looking for an application to display what a linq expression would do, in particular regarding the usage of multiple access to the same list in a query. Better yet, the tool would tell if the linq query is good. ...

Entity association problem

I have three tables: User: UserId (pk) FirstName Lastname Messages: MessageId (pk) Heading Body User_Messages: UserId MessageId Now, the entity designer only creates two tables with an association bewteen the tables. I am trying to select an item where UserId = value1 and MessageId ...

Hibernate with Oracle JDBC issue

I have a select query which takes 10 min to complete as it runs thru 10M records. When I run thru TOAD or program using normal JDBC connection I get the results back, but while running a Job which uses Hibernate as ORM does not return any results. It just hangs up ...even after 45 min? Please help ...

SQL Query to Show If Two Users in Same Group

I've got a database with 3 tables: users, groups, and groupmembers. users: id int username varchar(50) groups: id int name varchar(50) groupmembers: id int groupid int user int Given two user ids, how can I use one query to determine if they share membership in any group (not any particular one, but any group). I'd like the query t...

Limit second and third sql if no insert

I got on my php script $result1 = mysql_query("insert ignore into...this.... $result2 = mysql_query("insert into...that.... $result3 = mysql_query("insert ignore...again those all are different queries. when first query tries to insert, and if it has duplicate record, it does not enter this. well I dont want to run second and third ...

VBScript LDAP query to return mailserver property

Using the command line tool, ldapquery, the command is this: ldapsearch -h myldapserver uid=myloginname mailserver That returns a line like this: mailserver=CN=mymailserver/OU=xxx/O=xxxx I've tried every variation I can think of using VBS and I can query and get results returned from many other available properties, but some fail ...

Oracle Event Count Query

My SAMPLE table has the following five columns: sample_id (PK) (NUMBER) sampled_on (DATE) received_on (DATE) completed_on (DATE) authorized_on (DATE) I would like a query with one row per hour (constrained by a given date range) and five columns: The hour YYYY-MM-DD HH24 Number of samples sampled during that hour Number of samples r...

Any way to speed up this query?

This query is really slow. Takes between 9 and 10 seconds... SELECT DISTINCT a.* FROM addresses a LEFT JOIN contacts c ON c.id = a.contact_id LEFT JOIN organizations o ON o.id = a.organization_id ORDER BY c.last_name, c.first_name, o.name LIMIT 0, 24 If I comment out the ORDER BY clause the query runs much faster -- about 5 millisecon...

MS access update query to update part of string

Hi, I am trying to use an update query to update the first 3 characters of a string. but i am getting a syntax error my query is update table1, table 2 set left(table1.stringfield, 3) = table2.stringfield thankstksy ...