query

Problem with Full Outer Join not working as expected.

I have a query to subtract current balance from one table with previous balance from another history table. When a particular product has no current balance but has previous balance, I am able to subtract it correctly...in this case it will be like 0 - 100. However, when the product has current balance but no previous balance, I am unab...

Can I avoid to overwrite a column with a NULL value on INSERT query?

I have two different queries in my php page for the same table, the first one is executed if I have two different values for two columns, but in some case, i can use only the first value, can I do it with the same query or should I use two different queries? // query 1 "INSERT INTO my_table (column_1, column_2) VALUES ('$value_1', '$val...

[Mysql]: select UNIQUE w/ join

I have a series of related tables. Transaction_Type Transaction_ID (primary) Transaction_amount Transaction_Type Transaction Transaction_ID (primary) Timestamp Purchase Transaction_ID Item_ID Purchase_ID (primary) Item Item_ID Client_ID I need to select transaction_type rows based on a time stamp and client_id My query is as foll...

Update Procedure "N/A" to Empty String on MS Access

Hello, I currently have a table in MS Access called Total Registrants. How can I insert string "N/A" into the cells of the column "EventRegCompany" where there are blank cells? I created an update query UPDATE Test SET Test.eventRegCompany = "N/A" WHERE (((Test.eventRegCompany)=NULL)); Thanks! ...

Python - automating MySQL query: passing parameter

Hello Everybody, The code in the sequence is working fine, but looking to improve the MySQL code to a more efficient format. The first case is about a function that received a parameter and returns the customerID from MySQL db: def clean_table(self,customerName): getCustomerIDMySQL="""SELECT customerID FROM customer WHERE ...

Question about oracle xe search query

Hello all, this is my second time using ORACLE xe and Apex. Here is what I'm trying to do .. I'm trying to execute the following query SELECT * FROM EMPLOYEES WHERE JOB_TITLE = 'CLERK' but not from sql command prompt but from gui/apex and here is how- I have created page one with one textfield and one submit button. Now of course I'd...

Mysql Update + SELECT query help please.

I want to update data table for those who score exam id 1,2 more than 80. I try this UPDATE data SET column = 'value' WHERE (SELECT * FROM exams WHERE (id = '1' AND score >= 80) AND (id = '2' AND score >= 80)); It gives me 0 result. But it should have few hundreds results ANy help?? I think the problem is this: SELECT * FROM exams ...

Complex Django query over foreign keys

I have two models in the same application. The application is called "News", and it has two classes in its model called "Article" and "Category". class Category(models.Model): name = models.CharField(_("Name"), max_length=100) slug = models.SlugField(_("Slug"), max_length=100, unique=True) class Article(models.Model): categ...

Python - automating MySQL index: passing parameter

Hi Everybody, I have a function with a new improved version of the code for automatic table indexing: def update_tableIndex(self,tableName): getIndexMySQLQuery = """SELECT numberID FROM %s;""" % (tableName,) updateIndexMySQLQuery = """UPDATE %s SET numberID=%s WHERE numberID=%s;""" % (tableName,) updateIndex=1 ...

[PostgreSQL] Creating view from complicated select

Hi, I have quite complicated query from which I would like to create a view. The query looks like this: select s.avg as c3, fs.bayes, fs.sure, fs.visu, fs.fstd from ( SELECT AVG(q.c3), COUNT(q.c3), q.std FROM ( SELECT std, c3, ROW_NUMBER() OVER (PARTITION BY std ORDER BY id) AS rn FROM ssims WHERE obr...

How to combine data from 2 tables under circumstances?

I have 2 tables. One table contains posts and the other contains votes for the posts. Each member can vote (+ or -) for each post. (Structure example:) Posts table: pid, belongs, userp, text. Votes table: vid, userv, postid, vote. Also one table which contains the info for the users. What I want is: Supposing I am a logged-in membe...

little complex sql row postion

basically i have albums, which has 50 images init.. now if i show list of images, i know from which to which row is showing (showing: 20 to 30 of 50), means showing 10 rows from 20 - 30. well now the problem is, i want to select an image, but still show which postion was it selected, so i can move back and forth, but keep the postion too...

How can I tell LINQ to construct my entities with my own query data

I know it will sound strange but please don't mind: In C#, let's say I manually do with ADO or anything else: SELECT * FROM Member Then I want LINQ to construct my Member entities from the data I just retrieved myself from the query... Do you have an idea if it's possible? Thanks ...

SQL Server 2005 T-SQL Problem : Can you trust the Query Optimizer ? I know I can't !

Hello, This question is linked to my previous one ( posted as an anonymous user - now I have an account ) and, before I begin, I would like to give the credit to Rob Farley for providing the right indexing schema. But the problem is not the indexing schema. It's the Query Optimizer ! The query : SELECT s.ID_i , s.ShortName_v ...

how to select data depending on multple row's field

hi, i have a table like this: +------------------------+ |Key| value | name | +---+-------+------------+ 1 A john 2 B Mary 3 C Ben 4 A Ben 5 B john 6 C Mary how can i do a select which returns who has values of "A" and "B" (in t...

Sorting Float Column vs Int Column in SQL Server

I wonder if type of a column matters in terms of sorting performance. I have heard that int columns are sorted faster than float columns. Do you think it is correct? ...

Parsing AND, OR query to formulate sql

I'm developping a mini search engine, and I want to implement the feature of searches based on logic operators AND OR... I'm having a difficulty on parsing a query containing AND, OR, NOT... especially when it comes to parentheses... (cat or dog) not (bike not mike) For simple AND, and OR queries, it's obviously too simple and I figure...

How do I query on a number in Zend Lucene?

How can I create a Query to search for a number? $query->addTerm(new Zend_Search_Lucene_Index_Term('1', 'id'), null); $query->addTerm(new Zend_Search_Lucene_Index_Term('frank', 'name'), null); $queryP = Zend_Search_Lucene_Search_QueryParser::parse($query); $hits = $ix->find($queryP); echo $queryP; Returns; ...

MYSQL joining multiple queries based on condition

Table x x-id userid startdate enddate Table Y Y-id userid loginid startdate enddate In Table x a user will have only one entry but in Table y the same user can have multiple entry. select * from x-id where enddate BETWEEN DATE( CURDATE( ) ) AND DATE_ADD( CURDATE( ) , INTERVAL 7 DAY ) In this query i need to check with table x enddate...

Make an SQL request more efficient and tidy?

I have the following SQL query: SELECT Phrases.* FROM Phrases WHERE (((Phrases.phrase) Like "*ing aids*") AND ((Phrases.phrase) Not Like "*getting*") AND ((Phrases.phrase) Not Like "*contracting*")) AND ((Phrases.phrase) Not Like "*preventing*"); //(etc.) Now, if I were using RegEx, I might bunch all the Nots into one big (ge...