select

MySQL SELECT statement that groups results by id?

Hi all, I am trying to create a MySQL SELECT statement that will select a bunch of rows from a table and will group the results by the id of the row (multiple rows will have the same id). Here's an example of what I'm trying to do. Let's say I have the following table: id | name 1 | Art 1 | Arnold 1 | ...

Rails 3 - Category Filter Using Select - Load Partial Via Ajax

Hey. I am trying to filter Client Comments by using a select and rendering it in a partial. Right now the partial loads @client.comments. I have a Category model with a Categorizations join. This all works, just need to know how to get the select to call the filter action and load the partial with ajax. Thanks for you help. Categories c...

HTML Select DropDown list with multiple colours

Hi, Is it possible to have different colours for different items in the dropdown list? Eg: Option 1 = green Option 2 = blue etc ...

The best way to do :not in jQuery?

Hi, I have a menu in jQuery when you click on a link it opens up, but I want it so when you click somewhere else, anywhere else that is not the menu, it becomes hidden. At the moment I'm binding a click event to $(':not(#the_menu)') But this seems like I'm binding a click event to the entire minus the menu, is there a more efficie...

Does CSS have a "start over" feature?

I'm using calendar_date_select (henceforth CDS) in a Rails application, and have a stupid question. When I embed the CDS component in the middle of an already-CSS-styled page, all manner of things go ugly-wrong with it (spacing, fonts, etc.). Clearly the elements inside the CDS have inherited unwanted stuff from the styles already workin...

javascript. Select part of an image

Scenario. I want to identify things in an image by 'drawing' a rectangle round them. E.g. to select a face in a crowd. A sign in a street etc. How to use the mouse events to a) mousedown to start select area Grow a 'rectangle' to follow the mouse movements. b) mouseup to end selection. Retrieve the xy, xy of the box for use in furthe...

MySQL query pulling from two tables, display in correct fields

I'm trying to select all fields in two separate tables as long as they're sharing a common ID. //mysql query $result = mysql_query("SELECT * FROM project, links WHERE project.id = links.id and project.id = $clientID") //displaying the link if ($row['url'] != null){ echo "<div class='clientsection' id='links'>Links</div>"; ec...

Select the latest record for each category linked available on an object

I have a tblMachineReports with the columns: Status(varchar),LogDate(datetime),Category(varchar), and MachineID(int). I want to retrieve the latest status update from each category for every machine, so in effect getting a snapshot of the latest statuses of all the machines unique to their MachineID. The table data would look like Cat...

Django Multiple Choice Field / Checkbox Select Multiple

I have a Django application and want to display multiple choice checkboxes in a user's profile. They will then be able to select multiple items. This is a simplified version of my models.py: from profiles.choices import SAMPLE_CHOICES class Profile(models.Model): user = models.ForeignKey(User, unique=True, verbose_name_('user')) ...

nested sql statment using and

hi guys, how to make this work in mysql? select ID,COMPANY_NAME,contact1, SUBURB, CATEGORY, PHONE from Victoria where (city in ( select suburb from allsuburbs)) and CATEGORY='Banks' this below statement is working: select ID,COMPANY_NAME,contact1, SUBURB, CATEGORY, PHONE from Victoria where city in ( select suburb from allsuburbs...

Why can't I SELECT a parent field that doesn't have a child?

(rest_branches) is the table of restaurants. (phone_numbers) is another table which contains the restaurants phone_numbers, and it has a field called (branch_id) which references the restaurant id. When I try: SELECT * FROM rest_branches NATURAL JOIN phone_numbers I only get the restaurants which have a phone_number. What should I ...

How to get Top 5 records in SqLite ?

I have tried this which did not work. select top 5 * from [Table_Name] ...

Sqlite: Selecting records spread over total records

I have a sql / sqlite question. I need to write a query that select some values from a sqlite database table. I always want the maximal returned records to be 20. If the total selected records are more than 20 I need to select 20 records that are spread evenly (no random) over the total records. It is also important that I always select ...

Conditionally Summing the same Column multiple times in a single select statement?

I have a single table that shows employee deployments, for various types of deployment, in a given location for each month: ID | Location_ID | Date | NumEmployees | DeploymentType_ID As an example, a few records might be: 1 | L1 | 12/2010 | 7 | 1 (=Permanent) 2 | L1 | 12/2010 | 2 | 2 (=Temp) 3 | L1 | 12/2010 | 1 | 3 (=Support) 4 ...

Use jQuery to find and add an image tooltip

Hey people Okay, what I'm trying to accomplish is a simple tool tip that, when you hover over the name of a color, shows a little image of that color. The html markup looks like this: <label class="colorPicker"> <input type="radio" checked="" id="20" value="20" name="id[2]"> <img width="16" height="16" title=" DinoBlack Mat " a...

MySQL: Request to select the last 10 send/received messages to/by different users

I want to select the 10 last messages you received OR you sent TO different users. For example the results must be shown like that: 1. John1 - last message received 04/17/10 3:12 2. Thomy - last message sent 04/16/10 1:26 3. Pamela - last message received 04/12/10 3:51 4. Freddy - last message received 03/28/10 9:00 5. Jack - las...

Count times ID appears in a table and return in row.

SELECT Boats.id, Boats.date, Boats.section, Boats.raft, river_company.company, river_section.section AS river FROM Boats INNER JOIN river_company ON Boats.raft = river_company.id INNER JOIN river_section ON Boats.section = river_section.id ORDER BY Boats.date DESC, river, river_company.company Returns everything I need. But how wo...

using union in a construct sparql query

hello, i have such a sparql query: select ?s ?p ?o from <http://localhost:8890/DAV/ranking&gt; where { {<http://seekda.com/providers/cdyne.com/PhoneNotify&gt; so:hasEndpoint ?s. ?s ?p ?o} union {<http://seekda.com/providers/cdyne.com/PhoneNotify&gt; ?p ?o} } but i need a graph query (construct ord describe). unfortunatly i have no...

Zend_Db_Select: regrouping conditions in where clause

Hi, I would like to do something like this: $select = $myTbl->select() ->from('download_log') ->joinLeft(...... etc........ ->joinLeft(...... etc........ ->joinLeft(...... etc........); //Filter all configured bots (Google, Yahoo, etc.) if(isset($this->_config->statistics->bots)){ $bots = explode(',',$this->_config->statistics->bots)...

Need help with a conditional SELECT statement

I've got a stored procedure with a select statement, like this: SELECT author_ID, author_name, author_bio FROM Authors WHERE author_ID in (SELECT author_ID from Books) This limits results to authors who have book records. This is the Books table: Books: book_ID INT, author_ID INT, book_title NVARCHAR, featured_book B...