select

django ORM : how to make an select query with OR between two fields

I am new to django and need some quick help. How will the following sql statement be translated in django ORM? SELECT * from table_name WHERE field1 = v1 OR field2 = v2 Thanks in advance! ...

Can I Programmatically Select Text in UITextView?

Hello everyone, I want to select Text on UITextView, similar to the default "Select" and "Select All" pop options we see when we tap. I want to the user the ability to do that from my custom menu. I played with selectedRange but that doesnt seem to do the trick. Any ideas? Thanks ...

unknown column in where clause

$result = mysql_query("SELECT * FROM Volunteers WHERE Volunteers.eventID = " . $var); $sql = mysql_query("SELECT * FROM Members WHERE Members.pid = " . $temp); I am also doing or die(mysql_error()) at the end of both statements if that matter. My problem is that the first statement executes perfectly but in that table I store an attri...

ROW_NUMBER() VS. DISTINCT

Dear All, I have a problem with ROW_NUMBER() , if i used it with DISTINCT in the following Query I have 2 scenarios: 1- run this query direct : give me for example 400 record as a result 2- uncomment a line which start with [--Uncomment1--] : give me 700 record as a result it duplicated some records not all the records what I want is...

exiting from a blocking select call!

I am calling a third party API which creates a socket, does a connect and then calls select API by passing the socket to block forever. I don't have access to the socket. Is there some way in which I can make the select call come out from my application without having access to the socket? My platform is Windows. ...

SQL ENQUIRY In how to Get defined number of records

I have a select statement, retrieve about 1000 record I want to modify it to return only some records defined by @startIndex and @count e.g. : If I said @startIndex=20 and @count=20 the result will be : from the 21th record to 40th I try to make it, but it take the same time as if I retrieve the 1000 record what is the best way to do ...

MySQL Select statement Where table1.id != table2.id

I have a table of data which has posts, then I have a separate table of data which has deleted posts. What happens when a post is deleted is that it's ID get's added to the deleted table rather than removing the post entry. What is a clean efficient way of selecting all the posts from the posts table without selecting the ones that have...

jQuery - select onchange to slide in / slide out div or form

Hi, I am trying to enhance a form, by showing only relevant fields depending on initial selection via a form select field. It is an order form for 3 products and all 3 products have unique properties. My idea was to hide all the content in divs, then reveal the relevant div when the product is selected. I have found some solutions th...

Select distinct ... inner join vs. select ... where id in (...)

I'm trying to create a subset of a table (as a materialized view), defined as those records which have a matching record in another materialized view. For example, let's say I have a Users table with user_id and name columns, and a Log table, with entry_id, user_id, activity, and timestamp columns. First I create a materialized view of...

$_POST Returns empty for multiple select box

Ok, I am filling up my multiple select box with options from another select box via javascript like so: function addAction() { var actions = document.getElementById("actions"); var action_list = document.getElementById("actions_list"); var opt = document.createElement("option"); for (var i=0; i<action_list.options.length...

How to improve INSERT INTO ... SELECT locking behavior

In our production database, we ran the following pseudo-code SQL batch query running every hour: INSERT INTO TemporaryTable (SELECT FROM HighlyContentiousTableInInnoDb WHERE allKindsOfComplexConditions are true) Now this query itself does not need to be fast, but I noticed it was locking up HighlyContentiousTableInInnoDb, even though i...

Using parameterized function calls in SELECT statements. SQL Server

I have taken over some code from a previous developer and have come across this SQL statement that calls several SQL functions. As you can see, the function calls in the select statement pass a parameter to the function. How does the SQL statement know what value to replace the variable with? For the below sample, how does the query en...

Summarising grouped records in a dataframe in R

Hello all, I have a data frame in R that looks like this: > TimeOffset, Source, Length > 0 1 1500 > 0.1 1 1000 > 0.2 1 50 > 0.4 2 25 > 0.6 2 3 > 1.1 1 1500 > 1.4 1 18 > 1.6 2 2500 > 1.9 2 ...

How to select which Matlab version to start from shell or Matlab startup?

I have multiple Matlab versions installed on my PC. To say, R2006b, R2009b, R2010a. In this particular application I want to start R2009b when I start it from Shell. Is there any options at the time of startup to select which version to run? ...

Summarising grouped records in a dataframe in R (...again)

Hello all, (I tried to ask this question earlier today, but later realised I over-simplified the question; the answers I received were correct, but I couldn't use them because of my over-simplification of the problem in the original question. Here's my 2nd attempt...) I have a data frame in R that looks like: "Timestamp", "Source", "...

Walking through an SQLite Table

I would like to implement or use functionality that allows stepping through a Table in SQLite. If I have a Table Products that has 100k rows, I would like to retrive perhaps 10k rows at a time. Somthing similar to how a webpage would list data and have a < Previous .. Next > link to walk through the data. Are there select statements t...

How do I conditionally select a field from one of two tables?

I have two tables invoices and pending_payments both of which have the following rows in common: invoice_id and balance. I want to do a select in MySQL that'll work thus: [pseudo-code] if(invoice_id exists in pending_payments table) { select balance from pending_payments where invoice_id = yadayadayada } else { select balance f...

select SUM in Cake

When I tried using follow code to get the sum of the column named Serviceinfo.services $conditions = array('fields'=>array('SUM(Serviceinfo.services) as servicecount'),'conditions'=>array('time_id BETWEEN ? AND ?'=>array($startid,$endtid))); $services = $this->Serviceinfo->find('all',$conditions); I had to fetch the sum data with serv...

Sql query to get this result..

Consider i have a user table and I have three columns mobilePhone,homePhone and workPhone... I have to select homePhone for every user as first pref if there is no value    I'll go for mobilePhone and    if there is no value for it       I ll go for workPhone.... Any suggestion how it can be done in mysql.. ...

How to get this done in mysql?

Consider i have a registartion table and there is field prefLocationId and it contains value like this 1,2,3,2,1,4 and so many.... And i have a table prefLocation which looks like this Id LocationName 1 Chennai 2 Mumbai 3 Kolkatta 4 Delhi and i want to select record of users and show values like Chennai,Mumbai,Kolkatta,Mumbai,Che...