Questions tagged [select]

Select is a common keyword used to query data. 'select()' is also a programming function for triggering code based on file handle or other system activity. Do not use this tag for questions related to: HTML

In query languages (SQL, …)

SELECT is a statement in query languages, like SQL or SPARQL. It returns a result set of records from one or more tables.

SELECT queries require two essential parts. The first part is the WHAT, which determines what we want SQL to go and fetch. The second part of any SELECT command is the FROM WHERE. It identifies where to fetch the data from, which may be from a SQL table, a SQL view, or some other SQL data object.

Reference


In HTML

<select> is also an HTML user interface element for choosing one or more option(s) from a finite collection of elements. Do not use this tag for this purpose, use instead.


In .NET/LINQ

select is a keyword that can be used for queries on various data sources that implement specific features, directly from language itself. Do not use this tag for such questions, use instead.


In C and C++

select() is an important system call used by C and C++ programs and libraries that avoids busy waiting for network activity and other I/O to complete.


In Perl

In Perl 5, select() has two different uses. When called with four parameters, it calls the same syscall as C and C++. In this form it has limited portability. Otherwise it is called with one or no parameters and sets or gets current default filehandle for output. The filehandle is used e.g. by print if no other specified. Special variables like $| relate to it, too. This second form is perfectly portable.

In Perl 6 it has been completely dropped.


In Go

The select statement lets a goroutine wait on multiple channel operations. A select blocks until one of its cases can run, then it executes that case.

38465 questions
238
votes
17 answers

How to select multiple rows filled with constants?

Selecting constants without referring to a table is perfectly legal in an SQL statement: SELECT 1, 2, 3 The result set that the latter returns is a single row containing the values. I was wondering if there is a way to select multiple rows at once…
Blagovest Buyukliev
  • 42,498
  • 14
  • 94
  • 130
234
votes
20 answers

Select arrow style change

I'm trying to replace the arrow of a select with a picture of my own. I'm including the select in a div with the same size, I set the background of the select as transparent and I'm including a picture(with the same size as the arrow) in the right…
user1802439
  • 2,651
  • 3
  • 18
  • 21
228
votes
10 answers

Best way to do nested case statement logic in SQL Server

I'm 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…
Sophia
  • 5,643
  • 9
  • 38
  • 43
221
votes
7 answers

Select records from NOW() -1 Day

Is there a way in a MySQL statement to order records (through a date stamp) by >= NOW() -1 so all records from the day before today to the future are selected?
user1092780
  • 2,291
  • 3
  • 15
  • 10
214
votes
49 answers

Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc

I've heard that SELECT * is generally bad practice to use when writing SQL commands because it is more efficient to SELECT columns you specifically need. If I need to SELECT every column in a table, should I use SELECT * FROM TABLE or SELECT…
Dan Herbert
  • 99,428
  • 48
  • 189
  • 219
211
votes
7 answers

Does a break statement break from a switch/select?

I know that switch/select statements break automatically after every case. I am wondering, in the following code: for { switch sometest() { case 0: dosomething() case 1: break default: dosomethingelse() …
Matt
  • 21,026
  • 18
  • 63
  • 115
210
votes
16 answers

Fastest way to determine if record exists

As the title suggests... I'm trying to figure out the fastest way with the least overhead to determine if a record exists in a table or not. Sample query: SELECT COUNT(*) FROM products WHERE products.id = ?; vs SELECT COUNT(products.id) FROM…
SnakeDoc
  • 13,611
  • 17
  • 65
  • 97
206
votes
9 answers

Return Boolean Value on SQL Select Statement

How to return a boolean value on SQL Select Statement? I tried this code: SELECT CAST(1 AS BIT) AS Expr1 FROM [User] WHERE (UserID = 20070022) And it only returns TRUE if the UserID exists on the table. I want it to return FALSE if the UserID…
mrjimoy_05
  • 3,452
  • 9
  • 58
  • 95
202
votes
9 answers

Get index of selected option with jQuery

I'm a little bit confused about how to get an index of a selected option from a HTML