query

How can a SharePoint SQL connection be set to query by the current login name?

I have a SQL table that needs to be queried by the login name. So, using SharePoint designer I successfully created a database connection, but I can't use the properties exposed by Profile nor Session as input parameters because they are not supported (A dialog pops up with a message indicating this) How else can I query a SQL datasourc...

Complex query in django

Hay, i have a quite complex query i cant get working in django. My model is called Car(), and i want to perform this query on it query = "SELECT *, ((ACOS(SIN("+user_lat+" * PI() / 180) * SIN(lat * PI() / 180) + COS("+user_lat+" * PI() / 180) * COS(lat * PI() / 180) * COS(("+user_lon+" - lon) * PI() / 180)) * 180 / PI()) * 60 * 1.1515)...

Oracle 10g - Write queries results to file

Hello, I want to run 200+ select queries and append the results to a file. All queries are the same the only difference in the date-time variable. I don't have privileges to create a routine that's why I had to create all the queries. I don't have privileges to create a view or another table to store the results in. I don't have access...

How to do a parameterized query

[ Status: Learner ] I am attempting to implement a parameterized query but I am having problems. Jonathan Sampson recently hinted at how this could be done (#2286115), but I'm not following his suggestion correctly. Here is my script $cGrade = "grade" ; include_once ( "db_login.php" ) ; $sql = "SELECT last_name AS last_name ...

SQL Query to sum fields from different tables

Hello, I'm a humble programmer that hates SQL ... :) Please help me with this query. I have 4 tables, for example: Table A: Id Total 1 100 2 200 3 500 Table B ExtId Amount 1 10 1 20 1 13 2 12 2 43 3 43 3 22 Table C ExtId Amount 1 10 1 20 1 13 2 12 2 43 3 43 3 ...

Select database rows in range

I want to select the rows between A and B from a table. The table has at least A rows but it might have less than B rows. For example if A = 2, B = 5 and the table has 3 rows it should return rows 2 and 3. How could I get the rows in such a range? I am using Microsoft SQL Server 2008. ...

SQL Query to concatenate strings or add default value

Hello, I have to create a View that shows a field created by concatenating some other fields. The simple query that I use is this one: SELECT CODPROY, DESCPROY, USER, CODPROY + ' - ' + USER + ' - ' + DESCPROY AS Expr FROM dbo.PROY The problem is that USER may be NULL and in this case I have to insert a default text, ...

Optimizing WordPress SQL query for older posts list

On my WordPress site, when a user pages far back in the list of posts, the queries end up taking a couple seconds. I'd like to bring this down. Here's the query that's being executed: SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_s...

What is the best way to determine the count of records that will be returned by a query with rufus-tokyo?

I would like to determine the number of records that a query on a Tokyo Cabinet Table will return before I run the query. I am using the rufus-tokyo Ruby gem as my interface. What is the best way to do this? ...

Help with MySQL SELECT statement, multiple tables

I have the following tables: reg_season +--------+--------+---------+------+--------+ | season | league | team | wins | losses | +--------+--------+---------+------+--------+ | 1962 | AL | Yankees | 96 | 66 | +--------+--------+---------+------+--------+ postseason +--------+---------+----------+ | season | team | f...

CakePHP Model: COUNT(*) in Containable

I have a CakePHP 1.3 app and really enjoy the Containable behavior for fetching data. Let's assume I have Posts in one-to-many relationship with Comments. I use Containable to query (for pagination) a list of all Posts and the belonging Comments. But I'm only interested in how many Comments each Post has. I did not found any way to achi...

Group By with Count using NHibernate

Given the following tables: Resources: ID int, Name varchar(100), Address varchar(500), City varchar(100), etc. ResourceViews: Id int, resourceId int, userId int, viewDate DateTime every time a resource is looked at, an entry is added to the ResourceView table for that user. Here are the corresponding classes: public class Resource {...

[PHP] query-generated tables with many-to-many data fields, best practice?

You have two hypothetical tables: TABLE 1 [id] [item] [amount] [cost] 1 hat 20 10 2 shoe 7 45 3 belt 2 25 TABLE 2 (many to many) [item] [color] hat blue hat red hat yellow shoe black shoe white etc. etc. and when you run a query, you want to output a list ...

rails: how to solve that difficult query within rails

Hi everybody, I have a query for my Rails environment, which I don't really know how to solve...: I have users and products where any user owns multiple products: users m:n products I solved that with a sales table. for any product a user owns there is a more specific table sales 1:1 individualspecifications I need to get a...

NHibernate Named Query

Hi, I'm trying to learn about SQL named queries using NHibernate and I have the following code. The issue is that I get the following error : "Message: No value given for one or more required parameters." when I try to test the code from MBUnit. <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2...

SQL query to search for a record that has a certain text?

How can I query for a record that has certain text input from the user? For example in my table adapter function: SELECT Word, Description, Example FROM WordLists WHERE (Word LIKE @SearchKey OR Description LIKE @SearchKey OR Example LIKE @SearchKey) Obviously only record that has the exact text from certain input will be acquired...

SQL query to show difference from the same table

My application has a table that contains snapshot inventory data from each year. For example, there's a vehicle inventory table with the typical columns vehicle_id, vehicle_plate_num, vehicle_year, vehicle_make, etc, but also the year designating that the vehicle is owned. Querying the entire table might result in something like this: ...

mysql query against wildcard

I have a mysql query in php, using match / against to filter results. Im trying to get a wildcard after $string so the next character can be anything. Help? "SELECT * FROM $table WHERE MATCH (message) AGAINST('$string%' IN BOOLEAN MODE)" ...

parameterized query in ms access 2003 using vba

Ok. I want to use parameterized queries to avoid dealing with embedded double or single quotes (" or ') in my data. As a simple example, what would the VBA code look like for the parameterized verion of this? Dim qstr as String Dim possiblyDangerousString as String qstr = "SELECT MyTable.LastName from MyTable WHERE MyTable.LastName ...

SQL Query Returning Duplicate Results

Hi, I've been working out this query now for a while and I thought I had it where I wanted it, but apparently not. There are two records in the database (orders). The query should return two different rows, but instead returns two rows that have exactly the same values. I think it may be something to do with the GROUP BY or derived tab...