FAQ Database Discussion Community


Select2 with Ajax + PHP

php,jquery,twitter-bootstrap,select
I am trying to use select2 pulling data using ajax from php back end. I could not figure out the documentation as much as I would like to. I think i probably missed some taken for granted stuffs. Please can you help with a simple example. I started or like...

Groovy: run SQL SELECT LIKE from file with params

sql,select,groovy
The groovy code is import groovy.sql.* dbUrl = 'jdbc:sqlserver://server' dbUser = 'username' dbPassword = 'password' dbDriver = 'com.microsoft.sqlserver.jdbc.SQLServerDriver' sql = Sql.newInstance(dbUrl, dbUser, dbPassword, dbDriver) def sqlfromfile = new SqlFromFile() sqlfromfile.sql_filename='select_query.sql' sqlfromfile.read() try{ def result = sql.rows(sqlfromfile.result,[id:'01']) println result }catch(e){ println e } class SqlFromFile { def sql_filename def read(){ result=...

PHP - Find File in Directory By File Name [closed]

php,select,directory,filenames
I have a directory full of filenames that contain unix timestamps. file_1434320602.data file_1434320352.data file_1434320112.data file_1434320032.data How would I get about loading them up in PHP so that I can select the one which I needed?...

Javascript - return dynamic row data with checkbox input

javascript,forms,select,checkbox,tabular
I seem to only be able to find the answer to this problem in JQuery and I would really like a pure JS solution. I have a dynamically generated table that I build from a parsed JSON file. I added a checkbox for each row. My question is, do I...

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...

Which performs first WHERE clause or JOIN clause

sql,sql-server,select,join,where
Which clause performs first in a SELECT statement? I have a doubt in select query on this basis. consider the below example SELECT * FROM #temp A INNER JOIN #temp B ON A.id = B.id INNER JOIN #temp C ON B.id = C.id WHERE A.Name = 'Acb' AND B.Name =...

Selecting and removing a html select option without selecting by index or ID, using vanilla JavaScript

javascript,function,select,options
I need to remove an option on a select box, and I've figured out a potential solution in the code below, but it doesn't feel particularly 'safe' (if another developer decided to add an option to the backend, the option will re-appear). Is there a better way of achieving this...

How to see the table just modified in a script with Sql Developer

sql,oracle,select,plsql,oracle-sqldeveloper
I've this block in sql developer: begin delete from temp; insert into temp values (1); dbms_output.put_line('Done'); end; If I hit F5 the script runs fine. The table is updated with the value 1 and the "Script output" tab says 'Done'. However I would like to automatically visualize the table that...

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...

Append selected list elements into textarea, add own text

javascript,angularjs,select,textarea
On the basis of this post : Angularjs select elements from list and display in textarea I would like to add functionality : Fill textarea on the basis of chosen elements from the list. Add additional text inserted by user -> when user decides that he/she wants to add element...

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>...

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...

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()"...

How to change the value with a select in SQL?

sql,sql-server,select,alias
I need to have an other value instead of FULL and NONE but I must do it in the select. SELECT Calendar_Month,Series,Cnt FROM T_Cust_Eom_n where TYP='REB' and Series='FULL' or TYP='REB' and Series='NONE' order by Series desc,Calendar_Month Can I do this with an as anyhow?...

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...

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...

Cakephp3 transaction find query

mysql,select,transactions,cakephp-3.0
When making a transaction in cakephp3 and adding a get() query inside all works fine. But why is a find() query not performed inside the transaction? I have the following controller in cakephp3: <?php namespace App\Controller; use Cake\Core\Configure; use Cake\Network\Exception\NotFoundException; use Cake\View\Exception\MissingTemplateException; use Cake\Network\Session; use Cake\Event\Event; use Cake\Network\Http\Client; use Cake\ORM\TableRegistry;...

how to sum a field from 3 tables and display the results together

sql-server,select,sum
im using sql server and I have 3 tables called accnt, acc1152, and acc1167. each of these tables has an amnt field and a accno field with a few thousand records in it. i need to sum the entire amnt column for acc1152 and acc1167, then sum the amnt column...

MySql : issue with GROUP BY and COUNT clauses

mysql,sql,select,count
I have this table I would like to display products(with their type) that have at least two different types. Here : I have tried this : SELECT PRODUCT, TYPE FROM MYTABLE group by PRODUCT, TYPE HAVING count(PRODUCT) > 1; but it doesn't give me the result I want....

How to select a range of my table

mysql,sql,select,range
I have a table like this: (Pay attention to the sequence numbers for every word) // tablename +---------+----------+ | word | number | ---------------------- | jack | 1 | | jack | 2 | | jack | 3 | | ali | 1 | | ali | 2 | |...

group by access seperate column

sql,ms-access,select,group-by
I'm very new to SQL and have the following (seemingly simple) database query. I have a table containing all timetracking information for a set of employees: date employeeId timeIn timeOut 01/01/20 1355 12:00 4:00 01/01/20 1355 4:30 6:00 01/01/15 1234 9:00 12:00 02/01/15 5555 5:00 6:00 02/01/15 1111 1:00 4:00...

Condition on resultset of a select that return null or not null values-Java

java,sql,select,null
For an application,I am checking if a table is filled so that I can retrieve that from it; otherwise I will retrive from another table. For that, I use a select and checks if it has null values by wasnull(). If it does, I execute a query; otherwise, I execute...

How to select the last 12 months in sql?

sql,sql-server,select
I need to select the last 12 months. As you can see on the picture, May occurs two times. But I only want it to occur once. And it needs to be the newest one. Plus, the table should stay in this structure, with the latest month on the bottom....

SQL Server query syntax with single quote

sql,sql-server,sql-server-2008,select,escaping
I have in my database KIA car model like CEE'D. How to write right syntax to get all car where model = CEE'D Now I am using semipart of model SELECT make, model FROM Cars WHERE model LIKE '%CEE%' But now I need to get by full model name. How...

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...

Flag fields from table 1 that also bellowings to table 2

php,mysql,sql,select,join
I have two table (table1 and table2) where table2 is a subset of table1, what I am trying to do is a select statement that return a boolean if a field of tabl1 is also in the table2 For example: Table 1 has item1, item2, item3 and item4 Table 2...

I am using a select in form field. data is inserted properly but displayed id only instead of text

laravel,select
Create page <div class="form-group"> <label><b>STATUS</b></label> {!! Form::select('status', ['Draft','Published']) !!} </div> Index page @foreach($sliders as $slider) <tr> <td>{!! $slider->id !!}</a></td> <td>{!! $slider->status !!}</td> @endforeach Controller public function store(Slider $slider,CreateSliderRequest $request) { // $slider=$slider->lists('name','id'); $slider = $slider->create($request->all()); Session::flash('message', 'The...

How to perform boolean addition on an SQL select

sql,sql-server,select,sum,boolean
I have the following data in a database table column named timeSchedule 00100110 00010100 00110000 00110011 Boolean addition would result in 00110111 Is there a way to do this in sql? Something like select sumboolean(timeSchedule) from myTable Someone asked for DDL+DML.. here is an example: CREATE TABLE [dbo].[myTable]( [musPracticeID] [int]...

Swift Segment Control how to select more than one segment

swift,select,uisegmentedcontrol
I have a Segment Control in my app, I want to user to be able to click multiple of the segments. I googled and could not find any about this and there was no checkbox in Xcode for something like 'Allow multiple selection'. I found that in objective-c you weren't...

a simple select input is not working properly with angular-meteor

angularjs,select,meteor,angularjs-ng-repeat,angular-meteor
this is a weird thing: using angular-meteor library put a simple select input on the page: <div id="category"> <select ng-model="selectedItem"> <option ng-repeat="p in inputCategories" value="{{p.name}}"></option> </select> </div> select itself shows up, it has the correct number of options, but the actual option text is invisible! When inspected, it shows the...

AngularJS Filter two select inputs with values less than or equal to value

javascript,angularjs,select,filter,compare
I would like to setup two select inputs so that the combined value of either select input should be less than or equal to a specific value. Newbie to the AngularJS world so I may have overlooked something. I assume a filter but it might be ng-change that I should...

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...

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:...

How to create a SELECT query FROM “TABLE1 AND TABLE2”

sql,postgresql,select,join
I have a PostgreSQL database, with only SELECT permissions. In this DB there are two tables with the same structure (the same columns). I need to write several query in each table and join the results. There is a way for writing a query like this one? SELECT field1, field2,...

Knokout select : Set Selected Item by item name not value

jquery,select,knockout.js
i have a knockout select as following observable Array issuingCountries 0: ObjectCoordinatorRegion: "EU" Country: "Australia" CountryId: 14 Id: 1 2: ObjectCoordinatorRegion: "AU" Country: "Japan" CountryId: 16 Id: 2 html <select class="issuing_country" data-bind="options: issuingCountries, optionsText : 'Country', value:IssuingcountrySelected, optionsCaption:'---Select---', " > </select> My question , i have { Country: "Japan" }...

How to change multiple form elements via single select

html,forms,select,if-statement,onchange
I'm completely stumped at how I can change the opening tag to have 'method=post' if the second select option is chosen. I am using an Onchange for the form action, but can't figure out how to change the post method too. My latest attempt is with an IF statement as...

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]...

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" } ?> >...

Combining two select statements

sql,database,select,where
I have two statements as such: var chgAssociationQuery1 = (from a in sostenuto.PROBLEMS join b in sostenuto.S_ASSOCIATION on a.SERVICEREQNO equals b.FROMSERVICEREQNO join c in sostenuto.Changes on b.TOSERVICEREQNO equals c.SERVICEREQNO where b.FROMSERVICEID == 101001110 && b.TOSERVICEID == 101001109 && a.NAME.Contains(name) select new { ProblemReqNo = a.SERVICEREQNO, ProblemId = a.SERVICEREQID, ChangeReqNo =...

Understanding cartesian product in SQL

mysql,sql,select,join,cartesian-product
I am not able to understand how Cartesian product works. Consider the simple schema: mysql> select * from account; +----------------+-------------+---------+ | account_number | branch_name | balance | +----------------+-------------+---------+ | A101 | Downtown | 500 | | A102 | Perryridge | 400 | | A201 | Brighton | 900 | |...

Formatting dates in PostgreSQL

sql,postgresql,select,date-formatting
I have a field which its format is date with time as: YYYY-MM-DD HH-MM-SS for example: 2000-08-12 00:00:00 I want to get just the date part and change its format to DD/MMM/YYYY for example the expected result of the previous example will be: 12/Aug/2000 The field definition is: Ddate timestamp...

SELECT * FROM WHERE Query isn't retrieving any results

mysql,select,mysqli,fetch
I'm using a SELECT * FROM "" WHERE "" = "" query and I'm not sure what I'm doing wrong with it. I'm trying to select an item based on its PO which is a completely unique identifier to one row in the table. Here's my process in doing so:...

referencing mySQL query components

mysql,sql,select,alias
Is there a way to make reference to parts of a MySQL query within the same query? For example: SELECT 50000 AS starting_principle, .065*50000 AS interest, principle + interest AS principle_plus_interest The third column, principle_plus_interest in the query set gives me an error. Is there a way to code this...

SQL Optimization: query table with different where clauses

sql,oracle,select,sql-optimization
I have the following SQL query: SELECT ( SELECT SUM(c1) FROM t2 WHERE t1.c1 = t2.c1 AND t2.c3 = 'NEW' AND t2.c4 = TRUNC(SYSDATE) AND t2.c5 = 'N' ) SUM, ( SELECT sum(c2) FROM t2 WHERE t1.c1 = t2.c1 AND t2.c3 = 'OLD' AND t2.c4 = TRUNC(SYSDATE) ) SUM2 FROM...

Autoupdating Field Based on two