select interview questions
Top select frequently asked interview questions
I need a select which would return results like this:
SELECT * FROM MyTable WHERE Column1 CONTAINS 'word1 word2 word3'
And I need all results, including the strings with 'word2 word3 word1' or 'word1 word3 word2'
All words needs to be in the result.
Source: (StackOverflow)
Is it possible to create a temporary (session only) table from a select statement without using a create table statement and specifying each column type? I know derived tables are capable of this, but those are super-temporary (statement-only) and I want to re-use.
It would save time if I did not have to write up a create table command and keep the column list and type list matched up.
Source: (StackOverflow)
<select id="target">
<option value="1">...</option>
<option value="2">...</option>
</select>
Source: (StackOverflow)
I was under the impression that I could get the value of a select input by doing this $(this).val();
and applying the onchange
parameter to the select field.
It would appear it only works if I reference the ID.
How do I do it using this.
Source: (StackOverflow)
How can I check if a user has selected something from a <select>
field in HTML5?
I see <select>
doesn't support the new required
attribute... do I have to use JavaScript then? Or is there something I’m missing? :/
Source: (StackOverflow)
Can anyone tell me if a SELECT
command to MySQL is case insensitive by default? And if not, what command would I have to send so that I can do something like:
SELECT * FROM `table` WHERE `Value` = "DickSavagewood"
Where in actuality, the real value of Value
is dicksavagewood
.
Source: (StackOverflow)
I was wondering if it's possible to get jQuery to select an option, say the 4th item, in a dropdown box?
<select>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select>
I want the user to click a link, then have the select box change it's value, as if the user has selected it by clicking on the option.
Source: (StackOverflow)
I have a database with account numbers and card numbers. I match these to a file to update any card numbers to the account number, so that I am only working with account numbers.
I created a view linking the table to the account/card database to return the Table ID and the related account number, and now I need to update those records where the ID matches with the Account Number.
This is the Sales_Import
table, where the account number field needs to be updated:
LeadID AccountNumber
147 5807811235
150 5807811326
185 7006100100007267039
And this is the RetrieveAccountNumber
table, where I need to update from:
LeadID AccountNumber
147 7006100100007266957
150 7006100100007267039
I tried the below, but no luck so far:
UPDATE [Sales_Lead].[dbo].[Sales_Import]
SET [AccountNumber] = (SELECT RetrieveAccountNumber.AccountNumber
FROM RetrieveAccountNumber
WHERE [Sales_Lead].[dbo].[Sales_Import]. LeadID =
RetrieveAccountNumber.LeadID)
It updates the card numbers to account numbers, but the account numbers gets replaced by NULL
Source: (StackOverflow)
I have a stored procedure that returns 80 columns, and 300 rows. I want to write a select that gets 2 of those columns. Something like
SELECT col1, col2 FROM EXEC MyStoredProc 'param1', 'param2'
When I used the above syntax I get the error:
"Invalid Column Name".
I know the easiest solution would be to change the stored procedure, but I didn't write it, and I can't change it.
Is there any way to do what I want?
I could make a temp table to put the results in, but because there are 80 columns so I would need to make an 80 column temp table just to get 2 columns. I wanted to avoid tracking down all the columns that are returned.
I tried using WITH SprocResults AS ....
as suggested by Mark, but I got 2 errors
Incorrect syntax near the keyword 'EXEC'.
Incorrect syntax near ')'.
I tried declaring a table variable and I got the following error
Insert Error: Column name or number of supplied values does not match table definition
If I try
SELECT * FROM EXEC MyStoredProc 'param1', 'param2'
I get the error :
Incorrect syntax near the keyword 'exec'.
Source: (StackOverflow)
In SQL Server, it's possible to insert into a table using a SELECT
statement:
INSERT INTO Table (col, col2, col3)
SELECT col, col2, col3 FROM other_table WHERE sql = 'cool'
Is it also possible to update via a SELECT
? I have a temporary table containing the values, and would like to update another table using those values. Perhaps something like this:
UPDATE Table SET col1, col2
SELECT col1, col2 FROM other_table WHERE sql = 'cool'
WHERE Table.id = other_table.id
Source: (StackOverflow)
SELECT * FROM table ORDER BY string_length(column);
Is there a MySQL function to do this (of course instead of string_length
)?
Source: (StackOverflow)
I have a dataset objds. objds contains a table named Table1. Table1 contains column named ProcessName. This ProcessName contains repated names.So i want to select only distinct names.Is this possible.
intUniqId[i] = (objds.Tables[0].Rows[i]["ProcessName"].ToString());
Source: (StackOverflow)
<select size="2">
<option selected="selected">Input your option</option>
<option>Input your option</option>
</select>
What is the best way, using jQuery, to elegantly unselect the option?
Source: (StackOverflow)