query

Order of tables in join query

I found this paragraph in Oracle documentation if you want to select the name of each department along with the name of its manager, you can write the query in one of two ways. In the first example which follows, the hint /++ordered++/ says to do the join in the order the tables appear in the FROM clause with attempting...

SharePoint 2010: efficient union query across site collections?

In SharePoint 2010, I would like to create a list in one SiteCollection that queries data from several other SiteCollections that have common fields: Is this possible, and if so - can it be done efficiently? The current proposed solutions involves setting up EventReceivers on each of the SiteCollections that we want to query, and upd...

ZendFramework - Finding out what queries are being run - Easier way

Hi There, Was wondering if there is an easier way to see the queries are being being run by my models? I know the alternate options are xDebug and Firebug but was wondering an easier method. Anyone? Thanks ...

How to escape a single quote to be used in an OData query?

I am using OData to query my database. The following line of code works fine when “adapterName” just contains text. ds.query('/DataAdapters?$filter=Name eq \'' + adapterName + '\'', ifmgr_CreateAdapter_Step1, onGenericFailure, ''); If “adapterName” contains a single quote it fails. I tried escaping the single quote by using the follow...

Sphinx. Set of queries. PHP API

Hello. With little sign of the Sphinx. I have 5 pages. At one should look at the entire base. This is done next. config: source logs { type = mysql sql_host = localhost sql_user = root sql_pass = sql_db = bot sql_port = 3306 sql_query_pre = SET NAMES utf8 sql_query = SELECT * FROM logs sql_attr_uint = host s...

JPQL exclude subclasses in a query

If I have a class Apple that extends Fruit, how do I write a JPQL query to return all objects that are strictly Fruits and not Apples? ...

How can I order a query result same as the id specified in the WHERE condition?

I have a query like this SELECT * FROM test JOIN test2 ON test.id=test2.id WHERE test.id IN (562,553,572) GROUP BY test.id Its results are ordered like this: 553, 562, 572... But I need the same order that I specified in the IN(562,553,572) condition. How can I do that? ...

MongoDB extract only the selected item in array

Suppose you have the following: // Document 1 { "shapes" : [ {"shape" : "square", "color" : "blue"}, {"shape" : "circle","color" : "red"} ] } // Document 2 { "shapes" : [ {"shape" : "square", "color" : "black"}, {"shape" : "circle", "color" : "green"} ] } do query: db.test.find({"shapes.color":"red"}, {"shapes.colo...

[cakephp] how to retreive all product from the db using an id's list?

Good Morning People! i have an array of products id's: $product_ids = array(10,14,15,...); and i want to find all the corresponding products on the DB using Cakephp's ORM. I'm using Mysql so the query would be something like: SELECT * FROM products WHERE id IN ( 10, 14, 15,... ) I could use the query() function, but it's seems lik...

I need to store & query "relational, hierarchical, graph, document" hybrid data. I'm looking for the best DB solution.

I am working on what is currently a pet project. Soon it will be going into mainstream production. My biggest barrier is the data storage. The bulk of the data is "document" with specific indexes that would span across several types of data. So a single collection with indexing would work just fine. I know MongoDB, Caché, and M will ha...

mysql avg() not working as expected

Hello, I'm having some trouble with MySql right now. I have an query that works just fine, I'm using it for a while, but today I got stuck with this. The query is: select avg(valor), tipo_id, users_id, datetime from entries where users_id = '1' and tipo_id = 1 and date_format(datetime,"%Y-%m-%d") between "'2010-09-20" and "2010-10-20"...

Anyone know of a method / tool to compare ad hoc SQL queries?

Hi, I have to convert a lot of legacy SQL queries to stored procs (rewriting and tidying) and I'm looking for an efficient way to compare the results one by one to ensure I haven't modified the behaviour. I currently use SQLDelta but it requires me to pipe the results of each query into tables and transfer one to a separate server usin...

Ad Hoc Reports Hadoop

Hey guys, I want to allow people to put in simple text search terms, run a pig job(if that's best? it's what I know best) and output the results (the tsv file results?) so I can show them in a web interface. Is there anything that approaches this problem? Any thing known to link a few disjointed pieces of the flow I am going for, toget...

Best way to make a txt from a query from SQ Server automatic once a week in Visual Studio.

I need to make a txt and put it in a FTP server every week and it has to be automatic. So there are many options here. I can make a windows service that execute the process every week(My 1th option I think..). I can make a .exe made it run with a Task Scheduler every week. I can make a dts with a job (This does not work forme as I don...

how can i get mysql results with alphabetical pagination

how can i get mysql results with alphabetical pagination i.e i have 2 fields i.e id and name in mysql table and following html links for pagination A B C D E F G ....... by clicking on A i want to get results names starting with A how can i do that with php ...

MySQL slow query at first, fast for sub queries

PHP: I have a simple pagination script which uses two queries. MySQL: Using server version 4.1.25 - I have two tables (products, categories) with the item_num field tying them together to retrieve products via category and both have unique ID fields which are indexed and auto-incremented. They're both MyISAM types. Query #1: SELECT COU...

Using a form to update data in MySQL

Having trouble getting my form to UPDATE records in my database even after searching the web and viewing the other answers on stack-overflow. Here is my current NON functioning code: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { session_start(); $tablename = $_SESSION['MM_Username']; $amount=$_POST['amount'];...

Form Variable in PDO Query

A Submit button for a form located on my page triggers the code below, but I am unsure of how to save the numeric value of a textbox named 'amount' into a php variable which I can use in the below PDO query. I am unsure of the syntax. Thanks in advance! if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $amo...

How could I optimise this MySQL query?

I have a table that stores a pupil_id, a category and an effective date (amongst other things). The dates can be past, present or future. I need a query that will extract a pupil's current status from the table. The following query works: SELECT * FROM pupil_status WHERE (status_pupil_id, status_date) IN ( SELECT status_pupil_id,...

Doctrine 2: group by field alias (Error: '...' does not point to a Class. )

I got this Doctrine query: select upper(substring(e.name, 1, 1)) first_letter from Application\Models\Exercise e group by first_letter order by first_letter asc But it throws an exception with the message: Error: 'first_letter' does not point to a Class. If I leave out the group by and the order by,...