query

Parallel mysql queries in php?

I am sharding my data into multiple mysql databases, but sometimes I will need to gather information from multiple shards. How can I query multiple mysql databases in parallel in php? I've seen some examples of asynchronous curl requests and shell_exec, but is there a more direct way? ...

Optimizing unions

HI, im having trouble trying to optimize the following query for sql server 2005. Does anyone know how could i improve it. Each one of the tables used there have about 40 million rows each. I've tried my best trying to optimize it but i manage to do the exact opposite. Thanks SELECT cos , SIN FROM ConSisHis200...

Query vs. View

I want to know what is the difference between a query and a view in terms of performance. And if a view is costly, what else besides a query could I do to improve performance? ...

Pass Query String to rDirectory

Is it possible to pass a query string to Namescape's rDirectory? I'd like to build a web-app that can do a search and display the results in rDirectory, rather than first launching rDirectory and doing said search. ...

join two tables into one big table

I have two tables with the same columns, and I need to copy one table's rows to the other table's rows to create one big table with all the values from both tables. Right now I am doing this query to return the same thing: SELECT col1, col2, col3 from Table1 union SELECT col1, col2, col3 from Table2 However, it seems horribly ineffic...

Help I have problem with select query in JPA

i have problem i want to select name_magazine from magazine and i already import all library needed and Query q = EntityManger.createQuery ("SELECT name_magazine FROM Magazine"); List results = (List) q.getResultList (); For(Sting s : result) System.out.println(s); but when i run this code it's error. can someon...

SQL select join: is it possible to prefix all columns as 'prefix.*'?

I'm wondering if this is possible in SQL. Say you have two tables A and B, and you do a select on table A and join on table B: SELECT a.*, b.* FROM TABLE_A a JOIN TABLE_B b USING (some_id); If table A has columns 'a_id', 'name', and 'some_id', and table B has 'b_id', 'name', and 'some_id', the query will return columns 'a_id', 'name',...

How to insert a record and return the newly created ID using a single SqlCommand?

I'm using an SqlCommand object to insert a record into a table with an autogenerated primary key. How can I write the command text so that I get the newly created ID when I use the ExecuteScalar() method? ...

Using Min, Max and Count on HQL

Hello there. Does hibernate HQL queries support using select min, max, count and other sql functions? like select min(p.age) from person p Thanks ...

SQL Statement Help - Select latest Order for each Customer.

Say I have 2 tables: Customers and Orders. A Customer can have many Orders. Now, I need to show any Customers with his latest Order. This means if a Customer has more than one Orders, show only the Order with the latest Entry Time. This is how far I managed on my own: SELECT a.*, b.Id FROM Customer a INNER JOIN Order b ON b.CustomerID...

Access to multiple data sources using Oracle Brio

Trying to build a dashboard using Oracle's Brio. I have to access 6 different databases to grab the same type of data, aggregate it and display it. Except that when I do it, Brio grabs the data from the first source just fine. When I grab the data from the second data source, Brio replaces the original data with the second set. So I ...

How to change programmatically DataSet SqlCommand CommandText

Hello, I have a generated DataSet with bunch of tables. In one table I have a custom query that I use to select people that are older than 15 years. I would like to change this query during working program, so that the query will look like 'select * from people where age > 17'. Now it looks like 'select * from people where age > 15'. A...

Query on a record set

Hi, Will a query like this on a recordset work rs.open "select * from table where vd=1; update table set vd1 = 1 where vd=2 or vd=3;" or is there anything wrong thanks ...

When do you give up set operations in SQL and go procedural?

I was once given this task to do in an RDBMS: Given tables customer, order, orderlines and product. Everything done with the usual fields and relationships, with a comment memo field on the orderline table. For one customer retrieve a list of all products that customer has ever ordered with product name, year of first purchase, dates o...

Configure apache to treat static resources with "?" character in filename

Hello All, For various reasons, I have a bunch of static resources all with the following naming format: xxxxx?yyyyy where the x's are regular letter chars, and the y's numbers 0-9. Apache is truncating the filename in the GET request at the "?" - as this is traditionally used to delinate query params - and thus reporting the follow...

SqlSelect: Update if exists, Insert if not - With date part comparison?

I need to update a record in a database with the following fields [ID] int (AutoIncr. PK) [ScorerID] int [Score] int [DateCreated] smalldatetime If a record exists for todays date (only the date portion should be checked, not the time) and a given scorer, I'd like to update the score value for this guy and this day. If the scorer do...

MySQL subselect performance question?

I need advice regarding subselect performance in MySQL. For a reason that I can't change, I am not able to use JOIN to create quesry filter, I can only add another AND clause in WHERE. What is the peformance of: select tasks.* from tasks where some criteria and task.project_id not in (select id from project where project.is_templa...

Retrieving Comments from a PostGres DB

Hi There... Im running a project on a PostGres database and need to retrieve the comments on columns within the DB to be used as table headings and such. I have seen that there are a couple of built in functions (pg_description and col_description) but i haven't been able to find examples on how to use them and playing around with them ...

self join query

Consider the following table: mysql> select * from phone_numbers; +-------------+------+-----------+ | number | type | person_id | +-------------+------+-----------+ | 17182225465 | home | 1 | | 19172225465 | cell | 1 | | 12129876543 | home | 2 | | 13049876543 | cell | 2 | | 15064223454 | home | ...

Select unique XElements (by attribute) with a filter using LinqToXml

I have an XML document looking similar to this: <items> <item cat="1" owner="14">bla</item> <item cat="1" owner="9">bla</item> <item cat="1" owner="14">bla</item> <item cat="2" owner="12">bla</item> <item cat="2" owner="12">bla</item> </items> Now I'd like to get all unique owners (I actually only need the attribute value of the ...