& ldquo; & quot; and & ldquo; NOT IN & ldquo; in CakePHP 3

This question already has an answer here: Access variables from parent scope in anonymous PHP function 1 answer There is an example in the Cookbook: $query = $cities->find() ->where(function ($exp, $q) { return $exp->notIn('country_id', ['AFG', '

LPAD and RPAD so that the total length is 20 characters

I have a column in a table where values are like this: 105,65 106,8 107 108,1234 Now I have to output it in 16,4 format removing the comma. I tried REPLACE(RPAD(LPAD(AMOUNT, 16, '0'), 20, '0'), ',', '') But it is always right padding 4 zeros to the r

If something else in the multiple selection statement

Please consider the following SQL Schema and statement. http://sqlfiddle.com/#!3/06c46/1/0 Table: CREATE TABLE EcomGroupProductRelation ( GroupProductRelationGroupID varchar(10), GroupProductRelationProductID varchar(10), GroupProductRelationSorting

Transpose an unknown number of columns

I'm looking for an efficient way to convert rows to columns using T-SQL. This the sample data: +----+--------------+----------------+ | ID | ColumnName | Value | +----+--------------+----------------+ | 1 | FirstName | Name 1 | | 2 | FirstName | Name

How to accomplish this task by using SQL Server

If the student have two studentsubjectstatus as Merit studentperformance is Merit. If the student have two studentsubjectstatus as Pass studentperformance is Pass Else is a Fail So i need a new column studentperformance and the output will be like th

C # modifying strings

I'm working on an application in which I retrieve data from a database to be displayed in a table in my cshtml. One of the fields I'm calling is a date field. The data for it in the database is stored in the following format: MMDDYY i.e; 091504. For

Oracle vs MySQL in context

So, I'm aware this isn't exactly a programming question but I felt it was still appropriate. What is the difference between Oracles proprietary RDBMS, that they license, vs MySQL, an open source DBMS they bought? Performance? Support? Security? Featu

Link three SQL tables

I have three tables towns , patientsHome,patientsRecords towns Id 1 2 3 patientsHome Id | serial_number 1 | 11 2 | 12 2 | 13 patientsRecords status | serial_number stable | 11 expire | 12 expire | 13 I want to count stable and expire patients from pa

What level of isolation do I need for these invariants?

I have two tables, TabelA and TabelB. Both have an ID column that is the primary key. In addition, TabelB has an A_ID column. The other columns are not relevant here. create table TableA ( ID serial primary key, ..., ) create table TableB ( ID serial

SQL: Limits the Number of Rows Can Be Quested in SQL Server

I would like to force limit the number of records being queried from the SQL Server in a way that I can report back the to user that they need to optimize their query. Intending to use it a reporting tool where let's say the user is not supposed to e

How to convert this statement from MySQL to HQL?

This is the SQL statement: SELECT opc.contenido, COUNT(r.idOpcPregunta) from Opcionesrespuestas as opc LEFT JOIN Respuestasimples as r ON r.idOpcPregunta = opc.idOpcPregunta where opc.idPregunta ='6' GROUP BY opc.idOpcPregunta; This is a HQL select o

How to convert the data type varchar to timestamp mysql?

I have database mysql with table 'tblevel' with column 'waktu' with varchar data type. and the column hold values like this: 30-01-2014 12:19:09 The value will be converted to timestamp, because I have to do that for data viewing in graphic, in this

How to increase the number of MySQL variables

Friends, in my project I have a variable named bill_number; every time the PRINT bill button is clicked I want to increase the value of bill_number by one in the database. Please help me as soon as possible. set @bill_number = @bill_numer+1; This is

postgresql with postgis & amp; polygons

I'm working with postgresql with postgis. I have few questions: trying to insert into a table with polygon column using the following syntax: ST_GeomFromText('POLYGON((long1 lat1, long2 lat2, long3 lat3))') fails with the following error: function ge

SqlCommand If exists - update, if it does not exist - insert in

Hello I have got this following statement that I would like it to INSERT INTO if there wasn't found any value with id = 1 If it exist I would like to update I inspired by this: UPDATE Table1 SET (...) WHERE Column1='SomeValue' IF @@ROWCOUNT=0 INSERT

Can I replace the value of a column in Select CASE SQL?

Can I override a value in a column such that if a case is true, it tells value x to be equal to another dynamic value in the query. Here's pseudocode. I know this doesn't work. Select jobTitle, managerTitle, bigBossTitle, CASE WHEN jobtitle like '%DE

How to do mysql_fetch_array in Magento

I want to create a drop down option using Magento module that populate the data from the database I created. Previously, I have this code in My IndexController.php which is work. This is the first code. public function dropdownAction() { if (file_exi

Basic data, dynamic properties, or CAS sort?

I'd like to implement a dynamic property on a Core Data model but am unclear as to whether this is supported, and if so... how? The idea is to have a model with a set number of non-dynamic fields, such as created_at, updated_at, start_at, end_at, etc

Simplified CSV to SQL javascript file converter

Is there simpler way to convert CSV files to SQL file than this?: BufferedReader input = new BufferedReader(new FileReader(new File("c:\\file.csv"))); Writer output = new BufferedWriter(new FileWriter(new File("c:\\file.sql"))); try {

SQL summarizes min / max active for time ranges

This is an SQL problem I can't wrap my head around in a simple query Is it possible? The data set is (letters added for ease of understanding): Start End 10:01 10:12 (A) 10:03 10:06 (B) 10:05 10:25 (C) 10:14 10:42 (D) 10:32 10:36 (E) The desired outp