select

Default value for <select> tags

I've got a select with two 'special' options, a bit like this: <select> <option value="????">Choose one:</option> <option value="1">option1</option> <option value="2">option2</option> .... <option value="????">Free input</option> </select> When the user selects nothing, I should ignore the input. When the user selects 'free inp...

Inexplicable inner query

Hi, I have a nested SQL query that is exhibiting results which I can't understand. The query joins the PARTNER and USER tables via the PARTNER_USER table. A partner is basically a collection of users, and the objective of this query is to figure out when the 20th user registered with the partner that has ID 34: select p.partner_id id, ...

MySQL join query help

Basically I have a mysql query something like the following: mysql_query("SELECT n.title, v.value FROM posts n INNER JOIN votes v ON n.id = v.id"); And what I need to do is to grab the title from the posts table and the current vote value from the votes table. At the moment, votes aren't stored into the votes table unless a vote happ...

<select> ajax calls

Hey, I am using jQuery on my site and i have a update section on my project and I have three dropdowns: Completed? Hours Worked Who worked on this project? I am trying to create an ajax call using jQuery to when I select it, call a $.ajax() and send the data to my php page to update my mysql database. I am guessing I could do this:...

JQuery Click event not being triggered in Safari?

I'm trying to do something when a user selects an option from a select box - As simple as can be right? I'm using JQuery 1.3.1 to register a click handler with the id of the select box. Everything was fine until I tested using Chrome and Safari and found it didn't work. Firefox 3.05 - YES I.E 7.0.5730.13 - YES IE6Eolas - YES Sarafi 3...

Fetching records with slug instead of ID

I'm currently trying to find the best way (in term of usability and performance) when dealing with a situation like fetching records tagged with a specific tag, or category, or something like that. A good way (the way I wanted to do), would be to fetch records with the tag/category slug, so the URL would look like : http://stackoverflo...

Select "where clause" evaluation order

In Sql Server 2005 when I have multiple parameters do I have the guarantee that the evaluation order will always be from left to right? Using an example: select a from table where c=1 and d=2 In this query if the "c=1" condition fails the "d=2" condition will never be evaluated? PS- "c" is an integer indexed column, d is a large ...

Can select into add a new field to the resulting table?

I've got a SQL statement in SQL Server 2005 that looks something like this: SELECT * INTO #TempTable FROM FirstTable WHERE <complex where clause> What I would really, really like is to have the resulting temp table have an extra field that is essentially an integer field counting from 1 up in the order the where clause returned the re...

Time remaining on a select() call ...

I'm using select() on a Linux/ARM platform to see if a udp socket has received a packet. I'd like to know how much time was remaining in the select call if it returns before the timeout (having detected a packet). Something along the lines of: int wait_fd(int fd, int msec) { struct timeval tv; fd_set rws; tv.tv_sec = msec...

Any way to prevent "deselection" of highlighted text?

Highlight some text on this webpage, then click basically anywhere on the document. Your selection will disappear. Is there a way to prevent this behavior when the user clicks on a specific element, either by CSS or Javascript? E.g.: var element = document.getElementById("foo"); foo.onclick = function(e){ //some magic here that pr...

SQL query help

Hi, I wrote a query select u.user, g.group, u2g.something from users, groups, u2g where users.u = u2g.u and groups.g = u2g.g that returns data like this: user, group, something ---------------------- 1 , 3, a 1 , 5, b 2 , 3, c 3 , 3, d 4 , 5, e now I would like to limit this query in such a way th...

SQL UNION and ORDER BY

I have an annoying SQL statement that seem simple but it looks awfull. I want the sql to return a resultset with userdata ordered so that a certain user is the first row in the resultset if that users emailaddress is in the companies table. I have this SQL that returns what i want but i think it looks awful: select 1 as o, * from User...

SQL Nested Select

Hi, I am trying to construct a sql select statement that does the following: SELECT GetDate() Mon, GetDate() Tues But I also want to be able to put WHERE restrictions on each column (Mon, Tues). So I want something like this, but it is not correct: SELECT (GetDate() Mon WHERE (1=1)), (GetDate() TuesWHERE (1=1)) Please point me in ...

The select element should return 2 values.

I have a select box with options in it. The value of the options gets the id of the item that is displayed in each option. I do have an other value that should be linked on this option. Is there an easy way to do this? <select id="category" name="data[cat]"> <option value="12" label="0">A</option> <option value="7" label="0">B</option...

IE & Drop Down Menus triggering the Pop-Up Blocker

I have no idea why this is happening. I have some very straightforward code, replicated below, which works fine in all browsers except for IE 7 & 8. In those browsers, trying to expand the list of options in the select triggers the built-in Pop-up blocker bar. What gives? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "ht...

How do I write some SQL that will return results showing the number of rows that occured in each hourly period?

Hi, I need to produce a SQL report showing the number of times a particular event happened in each hourly period during the day. My table has a date/time column on it containing the time the event occurred. How do I do a count of the number of rows that fall within each each hourly period during the day? So I need to see output like t...

Best way to do nested case statement logic in SQL Server

I'm currently writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions. I'm currently using nested case statements, but its getting messy. Is there a better (more organised and/or readable) way? (I am using Microsoft SQL Server, 2005) A simplified example: SELECT col...

Finding unmatched records with SQL

I'm trying write a query to find records which don't have a matching record in another table. For example, I have a two tables whose structures looks something like this: Table1 State | Product | Distributor | other fields CA | P1 | A | xxxx OR | P1 | A | xxxx OR | P1 | B ...

How do I insert into a table if a value does not exist, but only for certain criteria? (MS SQL Server)

Hi, Im very new to SQL but need to write a query to do the following. Using MS SQL Server 2005. Profile DefinitioninProfile Definition ------ ------------------- ---------- ProfileID DefinitionID DefinitionID ProfileType ProfileID ...

How can you check (peek) STDIN for piped data in Perl without using select?

Hi, I'm trying to handle the possibility that that no arguments and no piped data is passed to a Perl script. I'm assuming that if there are no arguments then input is being piped via STDIN. However if the user provides no arguments and does not pipe anything to the script, it will try to get keyboard input. My objective is to provide a...