select

SQL - Distinct on two columns and summarized values on third

Hi! I have a table with 3 different IDs. I want to distinct on column 1 and 2 and summarize the values of column 3 (into one field - maybe comma separated string). The summarized field doesn't have to "look nice" (no problems with: '4,3,' (comma at the end)). I'm using MS SQL Server 2008. E.g: ID1 ID2 ID3 1 1 5 1 1 8 ...

selecting id and count(id) from table in mysql

Hi guys, I am trying to make a photo album system in php and mysql. I have this code for list all photo albums: SELECT albums.*, count(pictures.id) AS countpic FROM albums LEFT JOIN pictures ON (albums.id=pictures.album_id) GROUP BY albums.id ORDER BY albums.date DESC"); I want to list title of photo albums with photo thumbnails ...

jquery: populating a select list from an autocomplete?

The basic problem: selecting a few items from a list of thousands. The potential solution: I have an autocomplete field that searches the db, and returns a name/id pair. This is working fine. The next step is to preserve the selected IDs, and allow the user to remove some if needed. For this, I've been looking at using a select...

Retrieve & update 20000 data records stops working

Hi everyone, I am using the following code do get all data records from a MS SQL database and I try to update every single record. The code is used in a WebService. The issue is, that the code runs fine if I have 1000 data records but now I have 20000 data records an the code first returned with an timeout. Then I set the cmd.CommandTim...

How do you use an attr_accessor in a select form?

I am trying to capture the identity of a gallery so that I can create a form based around that particular gallery. So I put together a select form, and threw an attr_accessor in my controller. But its failing from all sorts of directions, and I figure its a problem with my syntax. Any whiz's know this? model attr_accessor :existing_g...

Selecting a node in the nested set model through a not-unique name

Hello, I am trying to manage the retrieval of a node in a nested set model table, not through the unique ID, but through the name (a string), and other nodes within the tree under different parents may be called the same way. As far as now I used an unique ID to get nodes inside the nested sets: SELECT node.name, node.lft, node.r...

SQL Query to show 3 user names from userID's in one Bug record.

I would like to show all the usernames who have interacted with a bug in MS Access. I do not understand how to reference the same Users.UserName field 3 times in my select statement? Here are my tables -------------------------------------------- Table 'Bugs' -------------------------------------------- BugID OpendBy ClosedBy ...

How to select Fruit object from Fruit ID (unique)

Is this the best way to select the Fruit object I need from the ID? So I'm taking the ID and returning its name, id being unique, so there will only ever be one result. If I don't use .Single() I get IQueryable but I just want the single object var fruitName = (from p in fruitDB.Fruits where p.FruitID ==...

Select most recent rows that match a condition in SQLite

Let's say I have a table: Name, status, timestamp And I want to select the rows that match status='active' but only those that have the most recent timestamp for each of them. So if there were rows like this: Bob, active, 5/10/2010 Bob, active, 6/12/2010 Ann, inactive, 6/12/2000 Ann, active, 9/3/2009 Ann, active, 9/25/2010 I'd wan...

MySql - Select Query - Joins

I have two tables User ID UserName 1 Name1 2 Name2 3 Name3 4 Name4 5 Name5 Item ID ItemName InsertedBy UpdatedBy 1 Item1 1 4 2 Item2 3 3 3 Item3 2 5 4 Item4 5 3 5 Item5 4 5 Resultant Table required ID ItemName InsertedBy UpdatedBy 1 Item1 Name1 Name4...

SQL - Select all rows added yesterday efficiently

Hi, I want to select all of the rows added to a table which were added "yesterday" i.e. the day before whenever I choose to run the query. At the moment my query looks like this: SELECT row_date (etc) WHERE row_date >= trunc(sysdate-1) and row_date < truc(sysdate); Is there a more efficient (and, hopefully, readable) way of ...

can't change options of a select element in a drupal web form

Hi, Im new to drupal. I had created web form with few elements and two select boxes. All went well. that was last week. Now, I want to change the values, and strangely I can't see list of Values anywhere in the form component page. I can't even see how to create a new selectbox and give new options. I think I kill some module responsib...

Dependent Selects in prototype

Hi, I have two <select>s with the same <option>s, and I need - using prototype - that when selecting an option in one of them, the same option is removed from the other select and additionally the latter must mantain its previously selected option. Any clues ? Is there a better way than remembering the last item selected, recreate the o...

How can I replace a standard textarea with "insertable" text fields?

Hi all, I'd like to be able to replace a standard HTML <TEXTAREA> input with insertable <INPUT> text inputs. By insertable, I mean having two TEXT form inputs (name, role) and an "Add" button after it to add a new name/role after this one if desired. Ideally I'd have 'role' in an HTML <SELECT> input (drawn from my database) but I'm not...

MySQL: Select multiple rows containing values from one column

Dear all, I'd like to find the car_id's of the cars that have 'FORD' AND 'SILVER' AND the user input value of '200' in the value column: table_cars +----+--------+----------+-----------+ | id | car_id | name | value | +----+--------+----------+-----------+ | 1 | 1 | MAKE | FORD | | 2 | 1 ...

my sql field sum using another field to diffrentiate and then sort it

hi again every one i would like to ask something about query using mysql i have this table called video_stat, and here's the field CREATE TABLE IF NOT EXISTS `video_stat` ( `id` int(11) NOT NULL AUTO_INCREMENT, `video_id` int(10) NOT NULL, `member_id` int(10) NOT NULL, `counter` int(11) NOT NULL, `daydate` varchar(15) NOT NU...

PHP/Mysql - Dynamically selecting data?

I'm a bit new to OOP, but i've been playing with it for about a month now. Usually, i create a class called Mysql which has a __construct function that connects to a database directly. And after that i have lots of different functions that gets or inserts data into different tables. On the bus home today, i began thinking and i came up ...

SQLite Query : Select Query with BETWEEN clause

Hi all I want to run this query in Android Application : SELECT field1 FROM table1 where field1 = ?(enteredField1) AND field2 = ?(enteredField2) AND enteredField3 BETWEEN field3 , field4 ; my DB schema table1(field1, field2, field3, field4, field5) enteredField1 , 2 , 3 = are parameters which is to be checked. I hope I am clea...

Grails: Add value of two g:select to a HTML multiple select list

I have two g:select comboboxes that I want to add to the multiple select list when clicking an image. Here is the function in javascript: function addToList(list,firstOpt, secOpt) { var y = document.createElement('option'); y.text = firstOpt + ' - ' + secOpt; y.value = firstOpt+'-'+secOpt...

Quicksand question in HTML page

I am using the Quicksand jquery scripts on an HTML page and using simple select controls: <select name="sort" style="vertical-align:middle;" id="cboSort"> <option value="1" selected="selected">Low to High</option> <option value="2">High to Low</option> </select> I want to be able to have the quicksand scripts run on page load ...