query

CakePHP: Query in Component?

Howdy, Got question, maybe even problem while creating CakePHP Component. Basically, I need to implement few quesries that can be accesses everywhere in my layout (sidebar statistics and so). When I try to query in Component, I got error about calling function on a non-object. Damn, can anybody explain me this one? Cheers! ...

Determine 'valid until' date in MySQL query

In this table I store changeable values for certain spids. As days go by, these values can change, and an spid can get a new value. Now I want to find out until when a certain value is enabled. This is the data for a single spids uid spid propertyvalue creationdate -------------------------------------------------- 1 3 ...

Plone catalog query help

I'm pretty new to querying in plone, and I was wondering what's an efficient way to return just images on the site using a catalog query, and searching by type. I don't want to have to restrict users to a given folder if I don't have to. I tried: catalog(object_provides="Products.ATContentTypes.interface.image.IATImage", ...

SQL query with limit on rows from one table, not the result set

I'm running a simple query with a join, similar to SELECT t1.a, t2.b FROM t1 LEFT JOIN t2 ON ... LIMIT 5 As t1 has-many rows in t2 ( any number above 2 ) the LIMIT statement does not return the first 5 rows from t1 and corresponding entries from t2, but 5 rows which usually include 2-3 rows from t1. How can I write this query to get ...

Identity Filter Linq .Where

I need to provide a null where clause that has no effect. Currently I have: f=>{f!=null;} However that doesn't really look right. If I were to Select clients, I use .Select(clients => clients) With my filter I also get a warning about not all code paths returning a result. ...

how would you write this sql to delete if either of two fields are in a set of values

Background: i have 2 tables: Components: (id, name) Dependencies: (id, hasaComponentId, isaComponentId) in this case the hasaComponentId and isaComponentId are both foreign keys into the components table joined by components.id Question i have a set of Ids that the user selects. I want a sql query that will delete records from...

Query Excel worksheet in MS-Access VBA (using ADODB recordset)

I'd like to query an Excel worksheet in VBA and specify conditions. The simple query "SELECT * FROM [PCR$]" works perfectly, but I don't know how to add a WHERE clause. I tried cmd2.CommandText = "SELECT * FROM [PCR$] WHERE ([B1] IS NOT NULL)" but then it complains about missing parameters. This is the complete code: Dim rs2 As New ...

Windows Workflow Foundation 4.0 and Tracking

I'm working with the Beta 2 Version of Visual Studio 2010 to get some advanced learning of how to use WF4. I'm using code similar to that in the SqlTracking sample from the SDK, and am trying to track complex objects, of types that I have created, that I have passed into the workflow as arguments. In the CustomerTrackingEventsTable in ...

CakePHP & Subselects

I got app that need to be recoded in CakePHP. I got following select with subselects: SELECT COUNT(*) AS item1, (SELECT COUNT(*) FROM portal_members) AS item3, (SELECT COUNT(*) FROM portal_reviews) AS item3, (SELECT COUNT(*) FROM portal_downloads) AS item4 FROM portal_articles ...

Slow MySQL Query Breaking my back!

so, I have tried everything I can think of, and can't get this query to happen in less than 3 seconds on my local server. I know the problem has to do with the OR referencing both the owner_id and the person_id. if I run one or the other it happens instantly, but together with an or I can't seem to make it work - I looked into rewriting ...

MySQL: Query to get all rows from previous month

Hi All, I need to select all rows in my database that were created last month. For example, if the current month is January, then I want to return all rows that were created in December, if the month is February, then I want to return all rows that were created in January. I have a date_created column in my database that lists the dat...

How to elegantly write a SQL ORDER BY (which is invalid in inline query) but required for aggregate GROUP BY?

I have a simple query that runs in SQL 2008 and uses a custom CLR aggregate function, dbo.string_concat which aggregates a collection of strings. I require the comments ordered sequentially hence the ORDER BY requirement. The query I have has an awful TOP statement in it to allow ORDER BY to work for the aggregate function otherwise th...

Optimizing a MySQL query with a large IN() clause or join on derived table

Let's say I need to query the associates of a corporation. I have a table, "transactions", which contains data on every transaction made. CREATE TABLE `transactions` ( `transactionID` int(11) unsigned NOT NULL, `orderID` int(11) unsigned NOT NULL, `customerID` int(11) unsigned NOT NULL, `employeeID` int(11) unsigned NOT NULL, ...

update statement in sql server 2005

Consider the following Dig, Assume that all the three tables have a column Is_Deleted by default it is set to 0... I want to update Is_Deleted=1 field of Customers table where CustId=2 only when the rows containing CustId=2 and Is_Deleted=1 in Orders and OrderItems Tables... I dont want to use Cascade option.. Any suggestion ...

need help with access query - removing duplicated rows

hi i have this table A-----B-----C 123 ----3--------5 123----44-------7 123----6--------8 how to delete duplicated rows - but leave only the firs row ? i'll get this result A----B----C 123----3------5 thank's in advance ...

Sql value which isn't for the needed date but first available

I've got this SQL QUERY in MS SQL 2005/2008 database which gets me Money Amount, Money Currency, Money Time and Currency Converter. I left join it with Table that has gathered information from polish national bank about currency converter per each day. Here's the query: SELECT t1.[TransakcjeGotowkoweKwota], t1.TypyWaluty, ...

Mysql date query to find if the current is within two dates?

In my table I have two fields: start_date and end_date. I'm just trying to retrieve rows where the current date is between the start and end dates. For some reason, I am not getting this at all. I've tried using between, but I keep getting empty sets even though I know that there are records that exist... I don't think I'm thinking a...

Simple MySQL Join problem

Im stumped by this simple query because its one I have not tried before. Ive got a User table, User_Widget table and a Widget table. A simple inner join shows me what widgets they have by joining user_widget.user_id = user.user_id. How would I show the widgets in the Widget table that they dont have? ...

how to approach this specific query

Hi, I have a rather complex logical query I'm trying to execute. Essentially there are a series of related tables. I am having difficulty figuring out a good way to approach it. Tables: Transaction - T_id Discount - D_id item_id Type (percentage or basic value) value Transaction_Discount - T_id D_id Item - item_id price ED...

Query direction issue

Hi, I am stuck at the start of a small project and I am not sure what would be the best way to go with a query etc. The story is that I have a table with members predictions on a particular sport. They have predicted the top 5 places of each event (about 19 events in total). Some of these predictions have been entered more than once as...