FAQ Database Discussion Community


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

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

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

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

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

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

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

PHP $wpdb Select?

php,mysql,wordpress,select
I could use some assistance with an sql query. I have a small 3 column table, id, ip, and birthday. id auto increments. I'm trying to select all birthdays that are associated with a specific ip, but I'm not sure if the SQL statement I wrote is correct. The var_dump...

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

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

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

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

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

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

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

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

Autoupdating Field Based on two