query

View vs ODBC query

I am designing a database in PostgreSQL on a dedicated server. I want certain complex queries to be run often, and the results to be accessible with ODBC/JDBC clients such as MS-Access or reporting software. As I see it, I have the option to either define a VIEW within PostgreSQL and import it using ODBC, or to define the query within t...

Mysql cut string, the first character?

Hi is it possible to cut string like this: String in "data" columns: ,123,456 Cut the first character i.e "," (comma). So the query is something like: Update users set data = cut first string... ...

Ordering by the difference between two averages

I have a single table called orders. It has 3 fields I care about: price, type, and bid. Bid is an int with either 0 or 1 depending on if the order is to buy or sell something. 1 is buy, 0 is sell. orders |typeID |price |bid| |1 |10 |0| |2 |20 |0| |3 |30 |0| |4 |50 |0| |1 |80 |0| |2 |...

JPA : optimize EJB-QL query involving large many-to-many join table

Hi all. I'm using Hibernate Entity Manager 3.4.0.GA with Spring 2.5.6 and MySql 5.1. I have a use case where an entity called Artifact has a reflexive many-to-many relation with itself, and the join table is quite large (1 million lines). As a result, the HQL query performed by one of the methods in my DAO takes a long time. Any advice o...

Access SQL Query Help

Hi Everyone. I have a query in which I need to perform using three entities listed below: LU_AppName SDB_AppHistory SDB_Session LU_AppName has field APPNAM, SDB_AppHistory has the field STARTTIME which is date/time and also SDB_Session has field DURATION. I need to run an SQL query to show me Citrix APPLICATIONS which have not been...

OSCommerce Product Listing Shows Inaccurate Count and Results Per Page

http://www.roguevalleyroses.com/rose_list.php?search_id=&class=&height=&growth=&color=&bloom_size=&bloom_type=&shade=&fragrance=&disease=&rebloom=&thorns=&zone=&hybridizer=Ashdown%20Roses&date_range=&text=&view=&show=&page=4 This is the page. The code that queries ...

How to query by partitionkey in Azure Table Storage?

I have the following TableServiceContext class for books, I want to query the table Books by the partitionKey, please ignore the fact that I'm using the partition key as the book name, this is just for my learning sakes public class BookDataServiceContext: TableServiceContext { public BookDataServiceContext(str...

Is something wrong with this MySQL query?

Hey guys, I'm trying to update a site that was coded horribly, and I think there is an error in this multiple IF statement. I've been Googling for a while and can't find any example of multiple IFs in a MySQL UPDATE query. The idea is, we want to update a certain column of the row based on a different column of the row. Here's the que...

How to return row of sum()s

I now find my original table structure was not good, so want to change it. But I am having a hard time designing queries to obtain totals in rows with the new structure. current structure: +----------+-------+-------+-------+-------+ | state | shop | item0 | item1 | item2 | +----------+-------+-------+-------+-------+ | 5 | ...

What's wrong with this SQL query?

The following query returns ORA-00904 error: SATIS: Invalid identifier. When I remove the line HAVING satis > 0, it works. What should I do? SELECT donem, bolge_adi, sehir_tasra "1=Ş, 2=T", COUNT(DISTINCT mekankodu) "M.SAYISI", SUM(b2b_dagitim + b2b_transfer - b2b_iade) satis FROM mps_view2 WHERE donem IN ('200612','20071...

Why won't Oracle SQL let us use aliases in conditions?

Oracle PL/SQL won't let users to use aliases in conditions. In most cases it's very practical for me to use aliases instead of long statements. What's the reason for that? What bad would happen if we could use aliases in conditions? Example case: http://stackoverflow.com/questions/2235166/whats-wrong-with-this-sql-query ...

Conditional Sql Query.

I am displaying a property from the following table given below. Now what i have to do is, find the property in the same location(suppose my property is located in sec-19, match for sec-19 and if none of them found there then search for the entire city) with the following condition that it should be posted 10 days back or if none is post...

How to make search engine query in Mysql&PHP?

Hello, I want to make a search engine in an intranet. Now i use this clause in PHP. $k = explode(" ",$_GET[key]); $sql = "select entreprise.*, employee.* where entreprise.* or employee.* like '%$k[0]%' or '%$k[1]%'"; But it seems doesn't work. Do you know where is wrong? Thanks in advance. Edit: $sql = "select * from entreprise...

How to Join tables to get the result

I am having data like below Table1 data: Attr1 Attr2 36 L 37 L 38 L 39 L 40 L 41 L 42 L 43 L 44 L 46 L 48 L 50 L 52 L 54 L 56 L 58 L 60 L 62 L 36 P 37 P 38 P 39 P 40 P 41 P 42 P 43 P 44 P 46 P 48 P 50 P 52 P 54 P 56 P 58 P 60 P 62 P 36 PL 37 PL 38 PL 39 PL 40 PL 41 PL 42 PL 43 PL 44 PL 46 PL 48 PL 50 PL 52 PL 54 PL 56 PL 58 PL 60 PL...

Possible to have more then one labelField in Flex?

I have a combo box that is currently getting its information from a database this seems to be working fine. Now I would like to have content from two fields displaying in the combo box at once. Say First Name & Last Name I've added the information to the query fine but the data displayed in the combo box seems to be controlled by the l...

Querying over 1,000,000 records using salesforce Java API and looking for best approach

I am developing a Java application which will query tables which may hold over 1,000,000 records. I have tried everything I could to be as efficient as possible but I am only able to achieve on avg. about 5,000 records a minute and a maximum of 10,000 at one point. I have tried reverse engineering the data loader and my code seems to b...

Which Union ALL approach should be used?

We have 15 audit trail tables that need to be combined to look for inventory adjustments with certain criteria only. Is it best to do a UNION ALL with all tables, and then filter for criteria, OR throw the criteria into the mix on each table before doing a UNION ALL? Each table is only a few thousand records and the final filtered list...

Large Forms = Large PHP/mySql Query Strings... Is There a Good Solution?

I've got a CMS I'm building where I've got a rather large form full of data to add to my database. This is where I collect my variables.... $orgName = $_POST['orgName']; $impact = $_POST['impact']; $headline = $_POST['headline']; $content = $_POST['content']; $subContent = $_POST['subContent']; $meterText = $_POST['meterText']; $mont...

Result consisted of more than one row Error 1172 mysql

Hello im having a hard time with this stored procedure. im getting the error: Result consisted of more than one row. here is my stored procedure: DELIMITER $$ DROP PROCEDURE IF EXISTS `dss`.`COSTRET` $$ CREATE DEFINER=`dwadmin`@`192.168.%.%` PROCEDURE `COSTRET`( TDATE DATE) BEGIN DECLARE done INT DEFAULT 0; DECLARE ls_id VARC...

MySQL Result consisted of more than one row

Hi there im just new here and i have a question regarding my error on mysql it said Result consisted of more than one row. I have no idea how to solve this your help is much appreciated! DELIMITER $$ DROP PROCEDURE IF EXISTS `dss`.`COSTRET` $$ CREATE DEFINER=`dwadmin`@`192.168.%.%` PROCEDURE `COSTRET`( TDATE DATE) BEGIN DECLAR...