FAQ Database Discussion Community


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

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

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

change the content of a select option

jquery,forms,select,text,options
I'd like to change the text shown in a select form, without changing the HTML elements. This is an example: <select class="myclass" name="myselect"> <option value="0">1</option> <option value="1">2</option> </select> I would like to change the "2" string into "TWO", for example, like: <option value="1">TWO</option> I'm not able to select the right...

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

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

Firefox dropdown menu click

html,firefox,select,drop-down-menu
I have a dropdown menu for languages in my website and it works fine in Google Chrome, Safari and Internet Explorer, but it is bugged in Firefox. This is the code: <a href=""> <select id="languageSelector" style="background-color: transparent" onchange="location = this.options[this.selectedIndex].value;"> <option value=".">ESPAÑOL</option> <option value="./en/index.html">ENGLISH</option> <option value="./de/index.html">DEUTSCH</option> <option...

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

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

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

select only one row that has the highest count in sql

sql,oracle,select
I need to select one row only which has the highest count. How do I do that? This is my current code: select firstname, lastname, count(*) as total from trans join work on trans.workid = work.workid join artist on work.artistid = artist.artistid where datesold is not null group by firstname,...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Customize a select with font-awesome

css,select,font-awesome
This is what I have actually: HTML <label class="select"> <select name="email" id="email"> <option>aaaa</option> <option>aaaa</option> <option>aaaa</option> <option>aaaa</option> <option>aaaa</option> <option>aaaa</option> </select> </label> CSS .cforms select { -webkit-appearance: none; -moz-appearance: none; appearance: none; } .select { position:relative; display: -moz-inline-stack; display: inline-block; vertical-align: middle; zoom: 1;...

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

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

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

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

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

select a row of matrix based on Date in R

r,function,select
I'm new in R.I have a small question. I want to select one row based on date. I write a function but it doesn't work.Here is my example. Thanks in advance for your help. Here my data sample: Example Date A B 1 01/01/2000 0.6765442 1 2 01/01/2001 0.1374231 10...

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

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

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

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

Autoupdating Field Based on two