FAQ Database Discussion Community


Adding multiple data in select option rails 4

ruby-on-rails,ruby,ruby-on-rails-4,select
I am using bellow code and function options_from_collection_for_select for generating options for user. <%= select_tag 'receiver', options_from_collection_for_select(@user, 'id', 'email') %> Above code generate bellow html: <select id="receiver" name="receiver" style="display: none;"> <option value="1">[email protected]</option> <option value="2">[email protected]</option> <option value="3">[email protected]</option> </select> But i want email with username, e.g...

no such column error - sqlite

android,sql,sqlite,select,android-sqlite
I get a strange error: E/SQLiteLog﹕ (1) no such column: Test 06-22 01:51:20.006 15089-15089/com.almas.mehr.sms E/AndroidRuntime﹕ FATAL EXCEPTION: main android.database.sqlite.SQLiteException: no such column: Test (code 1): , while compiling: SELECT * FROM groups WHERE title = Test at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1090) at...

SQL Select Statement - Column Ambiguously Defined even when defining which table each column comes from

mysql,sql,select
I'm doing a beginners course on SQL and databases, and I'm trying to write a select statement that will join two tables on Oracle Apex. I'm using join...on... to do so. The two tables each have a column named the same, with the columns filled with matching values. Obviously, they...

OrientDB - Result from 2 different tables

sql,database,select,orient-db
I have a database that has 2 V's classes ('User' that has 2 strings named Name and Surname ,'Cinema') and 2 E's classes ('isGoing' that has an Integer property named Day, 'Friend'). This select returns all the 'Cinema' that the 'Friend' of the initial Vertex are going on a specific...

MySQL select from 2 tables without having “shared” key

mysql,select
Searched the site and found some similar questions, but none of solutions worked in my case. I have 2 tables - clients and memberships. The structure is following: clients client_id other_fields... memberships membership_id client_id other_fields... The field submitted to form is "membership_id". Let's say submitted value is 5. I want...

jQuery - hide option element by value

jquery,select,hide,html-select
Trying to hide an option element from a list. I have tried several methods however, cannot seems to work. I need to call select by name as I cannot add ID or class. $('select[name*="boxes"] option[value="box6"]').hide(); here the fiddle: http://jsfiddle.net/q2nb08t6/ any suggestions?...

Sql string search

sql,string,search,select
This is my question: Find the capital and the name where the capital includes the name of the country. This is my answer: SELECT name,capital FROM world WHERE capital=concat(name,"NULL") I dont understand what should i do in the "WHERE" part. Should i do capital=concat(name,something?) or IN or LIKE? Can you...

Check for two decimal digit number in string

sql,sql-server,sql-server-2008,select
I have two sets of records Set 1: -11 -12 -12 AN '' -134 -125 +135 Set 2: 1.15 1.1 In Set 1 I need to check which values are either blank '' or start with a + sign and are greater than 125. In Set 2 I need to...

how select a dynamic id generated in php with jquery

jquery,select
this code generated in php id="sus- ... <--- is static and id="sus-d->id ?>" is my problem to select that <button class="btn btn-danger btn-xs" id="sus-<?= $D->d->id ?>" ><i class="icon-trash "></i></button> out put : id="sus-2131" so i want select all id's start with sus- with below function : jQuery('#sus-').btsConfirmButton({msg:"I'm sure!"}, function(e) {...

display number of elements depending on option selected

javascript,jquery,select,options
I'm trying to add a 3rd filter to track/display the number of elements shown depending on the option selected (#filter9). This is what I have so far, I got the code from: Filter based on combination of multiple select and single select elements. This is what i'm trying to edit:...

Using Sum in If in Mysql

mysql,sql,select,sum
I want to select the sum of values of my_field. The unit of my_field is in seconds. I don't want to exceed 24 hours, so when it exceeds 24 hours, I want it to select 24*60*60 = 86400. SELECT IF(SUM(my_field) > 86400, 86400, SUM(my_field)) ... This solution doesn't seem to...

How to access invisible Unordered List element with Selenium WebDriver, Java

java,select,selenium,selenium-webdriver,html-lists
This is the HTML code: <ul id="personalBar"> <li id="upload" style="display:none;"></li> <li id="personal"> <span class="translate"></span> <span id="userName">qaadmin</span> <div id="dropDownArrow"></div> <ul> <li id="pendingActivities" class="translate" onclick="eCommon.helper.viewAllPendingActivities()" translatekey="MANAGE_STORE">Manage Store</li> <li class="translate" onclick="eCommon.helper.outSourceViewReports()"...

why do I need to update nfds in select call when I remove fds from master set?

c,sockets,select
Given a select call like this: select(fdMax+1, &readFds, NULL, NULL, &timeoutVal) where readFds are updated whenever new fd is added existing fd is removed Whenever new fd is added, I update the fdMax. However, whenever existing fd is removed, I'm wondering if I really need to update the fdMax also...

Pandas DataFrame: Delete specific date in all leap years

python,select,pandas,leap-year
The following sequence is an extract of the pandas DataFrame that I've got: >>> df_t value 2011-01-31 -5.575000 2011-03-31 7.700000 2011-05-31 15.966667 2011-07-31 10.683333 2011-08-31 10.454167 2011-10-31 9.320833 2011-12-31 -0.358333 2012-01-31 -11.550000 2012-03-31 1.700000 2012-05-31 12.333333 2012-07-31 12.816667 2012-08-31 11.837500 2012-10-31 2.733333 2012-12-31 4.075000 2013-01-31 2.450000 2013-03-31 -4.262500 2013-05-31 11.491667...

f.select losing value when editing Rails 4

html,ruby-on-rails,forms,ruby-on-rails-4,select
I have an f.select in the new article page, and it works fine. However, when I edit the article, the value changes back to whatever is first in the options. Is there a way to keep the select value so users don't have to worry about redoing that when editing...

JQuery select input value from input text generate by php

php,jquery,select
i have this structure that i generate for each element finded by a search <?php foreach ($this->pneumatici as $pneumatico) :?> <div class="col-md-3 element-form"> <div class="input-group input-float"> <input type="hidden" name="codice" value="<?= $pneumatico->codice ?>" id="codice"> <input type="text" class="form-control" id="quantita" value="0" size="1" maxlength="2" <?php if ($pneumatico->quantita == 0){ echo "disabled" } ?> >...

Database Multiple select Query , Unable to Retrieve Desired Data

sql,sql-server,database,select,join
I have three Tables as given below , I want to search record on base of three Different cafeterias in Single query,I want to search record whether user give Brand_Name , Drug_Id, Generic Name It give same output I.E. all record of That Drug_ID ,I am new to Database, however...

Is there a way to count a number of distinct values? [duplicate]

sql,postgresql,select,distinct-values
This question already has an answer here: SQL to find the number of distinct values in a column 8 answers In PostgreSQL 9.4 I have a table: id p_id PK integer ----------------- 1 1 2 1 ............. 123122 2233 Is there a way to count all distinct p_id values...

How to find top usage of IP pairs in PostgreSQL?

sql,postgresql,select,sum
I have a table with source_ip and destination_ip and usage. now i want to find top usage for ip pairs. My table is like this: source_ip | destination_ip | usage 192.168.1.1 | 192.168.1.2 | 20 192.168.1.2 | 192.168.1.1 | 30 192.168.1.3 | 192.168.1.2 | 20 192.168.1.2 | 192.168.1.3 | 20...

mysql inner join query with multiple boolean conditions

mysql,sql,select
I have following two tables Table 1: creatives creative_id creative_name 1 xyz 2 pqr 3 abc Table 2: term_relationships creative_id term_id 1 1 1 2 1 3 2 1 2 2 2 4 3 1 3 2 3 3 I want to join the above 2 tables to get query...

PHP: How to push Select results to multi-dimensional array (partially working)

php,arrays,loops,select,multidimensional-array
I am new to PHP and hope someone can help me with this. I have a Select query that returns (among others) the values from two columns in a db table, "ID" and "en". When getting the results from the Select I would like to store both these values for...

python - how to check whether some given date exists in netcdf file

python,date,select,netcdf
I read my timesteps from a netcdf file: timesteps = ncfile.variables['time'] Now I would like to know whether some given date (say, June 23th) exists in that list. If it does, I want to omit it. The netcdf file contains arbitrary dates. I have no clue how to do this...

Erroneous query works when used as subquery - how? Why?

sql,sql-server,select,subquery,sql-server-2000
Let's consider two tables: MY_DB.dbo.MY_TABLE1 that does contain column MY_PROBLEMATIC_COLUMN MY_DB.dbo.MY_TABLE2 that does not contain column MY_PROBLEMATIC_COLUMN As expected, query1: SELECT MY_PROBLEMATIC_COLUMN FROM MY_DB.dbo.MY_TABLE2 Results with: Server: Msg 207, Level 16, State 3, Line 1 Invalid column name 'MY_PROBLEMATIC_COLUMN'. However, this query2, which uses query1 as a subquery, works: SELECT...

SQL Case Value Switching

sql,select,case
I am passing a series of double values in from another table ranging from -1 to 1. If the value is positive, I want to make it the difference between it and 1 (ie. 0.2 would then become .8). If value is negative, I want it to be the delta...

Selecting multiple values from a single LINQ Query

c#,linq,select
I am having issues selecting multiple values from a LINQ query. I Can actually get the results I am looking for but it's not how I would like it.. This is my query. var getMovie = from item in entList where item.EType() == "Movie" orderby item.Rating select new { item.Title,...

how to Select data from multiple tables with several conditions?

sql,oracle,table,select
There are tables FACULTIES (F_NUMB, F_NAME, F_TELEF) and STUDENTS (S_NUM, SURNAME, SPECIALITY, GROUP, FACULTY_NUMB). Please write SQL query to achieve faculties names in which the count of students are greater than in faculty “Computer science”. This is what i'm doing: select faculties.f_name, count(STUDENTS.S_NUM) from STUDENTS, FACULTIES where students.fac_num=FACULTIES.F_NUMB group by...

Nested SQL statement with AVG()

php,mysql,select
I have three tables I want to pull data from. One is a classes table that stores a list of classes offered including an id, time stamp, trainer id, start time, am/pm and the days a class is held. The trainer id is a foreign key that ties it to...

How can I add FOR UPDATE to a cakephp3 query?

select,transactions,sql-update,cakephp-3.0,isolation-level
Is there a way to add FOR UPDATE to a find (SELECT) query in cakephp3? I found this hack: http://bakery.cakephp.org/2012/04/14/SELECT-FOR-UPDATE-hack-kind-of-ugly-but-it-works-PostgreSQL-and-MySql.html but it does not work since the limit value must contain only of a number. Another discussion on a similar topic can be found under https://github.com/cakephp/cakephp/issues/3136#event-213462937....

How to show data from database depending on user's choice from a select

php,jquery,database,select,data
I have to make a select and when user choose option from it, it should be displayed data from database based on this select. I can't use submit. It only should be displayed this select and when option is selected, to show data from this select. I'm new to jQuery...

Add SQL SELECT COUNT result to an existing column as text

sql,sql-server,select,count
I have two tables: 1. TABLE [dbo].[ItemCategories]( [Id] [int] IDENTITY(1,1) NOT NULL, [CategoryId] [int] NULL, [StockId] [int] NULL, 2. TABLE [dbo].[Categories]( [Id] [int] IDENTITY(1,1) NOT NULL, [ParentCategoryId] [int] NULL, [CategoryName] [nvarchar](100) NULL, [Slug] [nvarchar](150) NULL And this query in SQL Server 2012 SELECT [CategoryName], [Slug], [ParentCategoryId], [Id] FROM [Categories] ORDER...

how to retrieve select option from php?

php,select,option
I am calling selected value twice in php instead of once..please anyone solve my problem?? Html part: <select name="mol[]" > <option value="">Choose Mode of License</option> <option value="standalone">Standalone</option> <option value"wan">WAN</option> <option value"lan">LAN</option> </select> php code: echo "<td>"; echo "<select name='mol' class='mol'> <option value='$row[mol]'>$row[mol]</option> <option value='standalone'>Standalone</option>...

Calling SELECT * on a primary key versus an attribute in SQL

mysql,sql,select,primary-key
I am currently studying for a final and have a question about one of the practice problems. The problem states: Consider the following two SQL queries over the relation R(A,B) where attribute A is the primary key. Query 1: SELECT * FROM R WHERE B > 50 OR B <=...

Search table based on linked text field from second table

mysql,sql,select,join
Not being an SQL wiz at all, browsing through the results here, I was unable to find a proper solution, although the problem itself is fairly simple. Two tables: products id title strings id language_en An entry in products may look like this: id = 1 title = 10 Corresponding...

Selecting Account Numbers with latest date

sql,select,join,subquery
I have been trying to solve this problem now for days. I have table called Stat with the following simplified structure and sample data: Customer BankID AccNumb Type Date Amount AccType Customer 1 Boa 5 Account Statement 2015-01-01 10000,00 Eur Customer 1 CS 10 Account Statement 2015-04-04 22000,00 Eur Customer...

psql max group by just for some columns

sql,postgresql,select,max,psql
I have a problem in a psql query. I don't know how to select only the maximum value from a subset of two columns. It's very hard to explain the problem without an example, so I write one: I have a table like that: Athlete | Category | Points at1...

SQL INSERT INTO WITH SELECT query

sql,sql-server,select,insert-into
Not being experienced with SQL, I was hoping someone could help me with this. I have a empty temp table, as well as a table with information in it. My outline of my query as it stands is as follows: CREATE TABLE [#Temp] (ID Int, Field1 Varchar) INSERT INTO [#Temp]...

is it possible select the hit field of the search query

mysql,sql,select
I need to search on both from_a and from_alt fields, but should select only the hit field(field which matches with search criteria) as from_airport sample table : +--------+-----------------+ | from_a | from_alt | +--------+-----------------+ | FRA | BER,MUQ | | JFK | CAL,FRA | +--------+-----------------+ sample query for normal selection:...

how to sum a field and distribute the sum between records in another table

sql,sql-server,select,sum
I have a table whose records consist of minor inventory. I need to sum the cost of these records and distribute the sum in another table based on the price of the record. for example. say the sum of the inventory is is $1000, and I have 4 jobs in...

Merge results from two separate columns into one elongated column

sql,oracle,select
My table: ID Name Status1 Status2 ------------------------------------- 1 foo bar grain 2 bar foo sball 3 foo bar grain 4 far boo sball I need for it to actually come out like this: ID Name Status ------------------------------- 1 foo bar 1 foo grain 2 bar foo 2 bar sball 3...

Dynamically select from a dynamically generated dropdown

php,html,select,drop-down-menu
I have a dynamically generated dropdown list - list of course identifiers and names. On the basis of a variable, “assigned_course_id”, I would like to preselect the appropriate value from the dropdown list. My best attempt is as follows. Thanks in advance for your assistance. <select name="course_id" id="course_id"> <?php $assigned_course_id...

Autoupdating Field Based on two