select

SQL User Defined Function Within Select

I have a user defined function in SQL called getBuisnessDays it takes @startdate and @enddate and returns the number of business days between the two dates. How can I call that function within my select? Here's what I'd like to do.. SELECT getBusinessDays(a.opendate,a.closedate) FROM account a WHERE ... ...

Database and EF performance concern?

I have a basically sql select question that people gave me different answers over the years. Say I have a couple of tables designed each with over 40 columns and potentially will hold ten and thousands of row, I'm using SqlServer2005. On joining these tables, in the where clause if I have things like select * from t1, t2 where t1.User...

PHP join help with two tables

Hi. I am just learning php as I go along, and I'm completely lost here. I've never really used join before, and I think I need to here, but I don't know. I'm not expecting anyone to do it for me but if you could just point me in the right direction it would be amazing, I've tried reading up on joins but there are like 20 different met...

SQL Select based on Link Field

I feel like an idiot asking this... Table 1: users id serial person integer username char(32) Table 2:persons id serial name char(16) Can I run a query that returns the name field in persons by providing the username in users? users 1 | 1 | larry123 persons 1 | larry 2 | curly SQL? select name from persons where users.person=p...

How to signal select() to return immediately?

I have a worker thread that is listening to a TCP socket for incoming traffic, and buffering the received data for the main thread to access (let's call this socket A). However, the worker thread also has to do some regular operations (say, once per second), even if there is no data coming in. Therefore, I use select() with a timeout, so...

javascript options selected IE6 vs. FF2

the following js works fine in FF2 but in IE6 the dropdown always selects one option to early, IE -> testix2 vs. FF2 -> testix3 If we add an alertBox somewhere in the script, it also works fine in IE6. But how to solve this without an alertBox? tia <script language="JavaScript" type="text/javascript"> <!-- function Entry(value, name, s...

SELECT on a nullable reference

Hello, I have a relationship between two tables, authors and styles. Every author is associated with a style, with the special case where an author doesn't have a style (IS NULL). There's no problem in setting the reference to NULL, but there's a problem doing a query to select the authors and styles. For example, the query: SELECT ...

Is it possible to concatenate strings from multiple rows and tables into one result column?

I am trying to write a MySQL query that retrieves one record from table "projects" that has a one-to-many relationship with table "tags". My application uses 4 tables to do this: Projects - the projects table Entities - entity table; references several application resources Tags - tags table Tag_entity - links tags to entities Is it p...

When is the proper time to use the SQL statement "SELECT [results] FROM [tables] WHERE [conditions] FETCH FIRST [n] ROWS ONLY"

I'm not quite sure when selecting only a certain number of rows would be better than simply making a more specific select statement. I have a feeling I'm missing something pretty straight forward but I can't figure it out. I have less than 6 months experience with any SQL and it's been cursory at that so I'm sorry if this is a really s...

Swapping option boxes in IE?

My client asked me (a js client side programmer) to change the order of the options so that their company's option appears at the top of a select box when the page loads. The following code works in FF but fails in IE7 when I try to swap two options: function load{ var shippingLocation = document.getElementById("location"); var ...

Boost Message Queue not based on POSIX message queue? Impossible to select(2)?!

I thought I'd use Boost.Interprocess's Message Queue in place of sockets for communication within one host. But after digging into it, it seems that this library for some reason eschews the POSIX message queue facility (which my Linux system supports), and instead is implemented on top of POSIX shared memory. The interface is similar e...

Sql, selecting and updating

Hi, I am trying to select 100s of rows at a DB that contains 100000s of row and update those rows afters. the problem is I don't want to go to DB twice for this purpose since update only marks those rows as "read". is there any way I can do this in java using simple jdbc libraries? (hopefully without using stored procedures) update: ...

Can't get the object from a cell in jqGrid (jQuery)

This is the issue, when I define the ddl (drop down list or select box) I don't know the selected value. When a user edits a row, the user can select an item from the list. But the selected item isn't set. I want to set the selected item when the user clicks a button to edit the row. The proper way, I think, is to get the ddl that was ...

How C# Compiler choose SelectMany when translating LINQ expression?

There are 4 overloaded signatures for Enumerable.SelectMany. To make it simple, we ignore the two signatures with int argument. So we have 2 signatures for SelectMany: public static IEnumerable<TResult> SelectMany<TSource, TResult>( this IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector ) public static I...

Is it possible to use JS to open an HTML select to show it's option list?

Is it possible to use JavaScript to open an HTML select to show it's option list? ...

PHP & MYSQL: How to resolve ambiguous column names in JOIN operation?

I have two tables in my database: NEWS ('id' - the news id, 'user' - the user id of the author) USERS ('id' - the user id) I want to make a SELECT * FROM news JOIN users ON news.user = user.id, now when I get the results in PHP it's something like: $row = mysql_fetch_array($result), and get column names by $row['column-name']... how ...

mysql select - how to retrieve a result for threaded/nested messages?

I'm creating a threaded message board and I'm trying to keep it simple. There's a message table, and then a replies table that has an 'reply_id' field that can be null to indicate a top level response, or a value that indicates a threaded response. I'm a bit confused on how to do a SELECT call on this type of table though? Reply -id...

Another SQL tutorial question: Field > 0?

Alright, this one (3a; sample problem with provided answer) has got me scratching my head: bbc(name, region, area, population, gdp) 3a. Find the largest country in each region: SELECT region, name, population FROM bbc x WHERE population >= ALL (SELECT population FROM bbc y WHERE y.region = x.region AND...

Selecting from multiple MySQL tables

I have a few tables that have similar fields but not exactly the same. The same fields they have are description (text field) and modified (unixtime) I would like to select the last modified items from these tables based on unixtime. I cant use UNION since the tables aren't the same and the multiple table select times out. I've been t...

How to create virtual column using MySQL SELECT ?

Hi, If I do SELECT a AS b and b is not a column in the table, would query create the "virtual" column? in fact, I need to incorporate some virtual column into the query and process some information into the query so I can use it with each item later on. ...