query

SQL Get Latest Unique Rows

I have a log table, each row representing an object logging its state. Each object has a unique, unchanging GUID. There are multiple objects logging their states, so there will be thousands of entries, with objects continually inserting new logs. Everytime an object checks in, it is via an INSERT. I have the PrimaryKey, GUID, ObjectStat...

WordPress - Each page of paged posts all show same posts

I set up a pagination function for my wordpress blog. When clicking to the next page, the URL is correct: "/page/1", "/page/2", "/page/3" etc, but the actual posts don't change from page to page (page 2 and page 3 still display the first page of posts). Here's the code I'm using for the loop: Edit 4/24/10: I removed the 'offset' => 1, p...

grails: quering in a composite structure

hey i have the following domain model: class Location { String name static hasMany = [locations:Location, persons:Person] } class Person { String name } so basically each location can hold a bunch of people + "sub-locations". what is the best way to recursively query for all persons under a location (including it's sub l...

how to simplify this database update query (php)

How could I simplify this update instruction? Whenever a client buys an item it will update the sales with 1. $this->db->query('SELECT amount FROM shop_items WHERE itemid='.$itemid.''); $new_amount = $item->amount+1; if(!$this->db->query('UPDATE shop_items SET amount='.$new_amount.' WHERE itemid='.$itemid.'')): return false; ...

SQL query to return data from two separate rows in a table joined to a master table

I have a TWO tables of data with following fields table1=(ITTAG,ITCODE,ITDESC,SUPcode) table2=(ACCODE,ACNAME,ROUTE,SALMAN) This is my customer master table that contains my customer data such as customer code, customer name and so on... Every Route has a supervisor (table1=supcode) and I need to know the supervisor name in my t...

Java Shoutcast Query

Hi there, I have a Java IRC bot which i would like to query a shoutcast server and return basic information (song playing etc). Can someone guide me in the right direction? Thank you. ...

MySQL enters another value that the one given by PHP

Hello, The big problem : mysql does not stores the information i told him to via PHP Example (this req is an echo just before the query) : INSERT INTO serveur (GSP_nom , IPserv, port, tickrate, membre, nomPays, finContrat, type, jeux, slot, ipClient, email) VALUES ( 'ckras', '88.191.88.57', '37060', '100' , '', 'Allemagne','20110519...

MS Access query for time

Following data and using MS Access with VB6 UserID UserName LogTime LogDate 1 S 9:00 21/5/2010 1 S 10:00 21/5/2010 1 S 11:00 21/5/2010 1 S 12:00 21/5/2010 1 S 14:00 21/5/2010 1 S 17:00 21/5/2010 Need Output as in below 6 co...

MySQL limit from descending order

Hello, Is it available to write a query to use same "LIMIT (from), (count)", but get result in backwards? In example if I have 8 rows in the table and I want to get 5 rows in two steps I would: first step query: select * from table limit 0, 5 first step result: first 5 rows; second step query: select * from table limit 5, 5 se...

SQL 2005: Select top N, group by ID with joins

I'm having real difficulty with a query involving 3 tables. I need to get the 3 newest users per department grouped by department names. The groups should be sorted by the users.dateadded so the department with the newest activity is first. The users can exist in multiple departments so Im using a lookup table that just contains the ...

Using a variable in a mysql query, in a C++ MFC program.

Hi, after extensive trawling of the internet I still havent found any solution for this problem. I`m writing a small C++ app that connects to an online database and outputs the data in a listbox. I need to enable a search function using an edit box, but I cant get the query to work while using a variable. My code is: res = mysql_perf...

Query that ignore the spaces.

What's the best way to run a query so that spaces in the fields are ignored? For example the following queries.... SELECT * FROM mytable WHERE username = "JohnBobJones" SELECT * FROM mytable WHERE username = "John Bob Jones" . would find the following entries: John Bob Jones JohnBob Jones JohnBobJones . I am using php or python...

'And' operator in Linq

I have a query that prints userid in label1 when username is entered.Works fine; but i want to write query for username and password that prints userid. so how can i write it? i tried writing using 'and' operator but dont seems to work. int id = (from auser in lq.logins where auser.username == userNameString //&& auser.Passwo...

SQL Server Query Question

Running SQL Server 2008, and I am definitely a new SQL user. I have a table that has 4 columns: EmpNum, User, Action, Updatetime A user logs into, and out of a system, it is registered in the database. For example, if user1 logs into the system, then out 5 minutes later, a simple query (select * from update) would look like: EmpNum...

Is it possible to query a XML file with SQL?

Currently I'm working on a case where we don't want to change to much on a c#/wpf program, but like to add a feature. Currently we allow certain users to add sql queries to a database to retrieve customer data, hereby a custom connection string/ provider name must be specified. With this information it's possible to create the connection...

Convert sql query

I have used this query in sql,pls convert this query to use for access database. Table structure is UserID,Username,LogDate,LogTime WITH [TableWithRowId] as (SELECT ROW_NUMBER() OVER(ORDER BY UserId,LogDate,LogTime) RowId, * FROM @YourTable), [OddRows] as (SELECT * FROM [TableWithRowId] WHERE rowid % 2 = 1), ...

oracle select query - index on multiple columns

Hello. I'm working on a sql query, and trying to optimise it, because it takes too long to execute. I have a few select and UNION between. Every select is on the same table but with different condition in WHERE clause. Basically I have allways something like : select * from A where field1 <=TO_DATE ('01/01/2010', 'DD/MM/YYYY') AND fie...

Using variable from Code-behind in SQL Query, asp.net C#

I am trying to use a variable from the code-behind page in a sqlDataSource WHERE statement. I am using Membership.GetUser().ProviderUserKey to obtain the UserId of the logged in user and I would like to only show record that have this UserId as a foreign key. How can I write the SQL for this? Thanks much, Carl Here is what I have so fa...

Complex SQL query... 3 tables and need the most popular in the last 24 hours using timestamps!

Hey guys, I have 3 tables with a column in each which relates to one ID per row. I am looking for an sql statement query which will check all 3 tables for any rows in the last 24 hours (86400 seconds) i have stored timestamps in each tables under column time. After I get this query I will be able to do the next step which is to then c...

Weighted Average with LINQ

My goal is to get a weighted average from one table, based on another tables primary key. Example Data: Table1 Key WEIGHTED_AVERAGE 0200 0 Table2 ForeignKey LENGTH PCR 0200 105 52 0200 105 60 0200 105 54 0200 105 -1 0200 47 55 I need to get ...