SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and - laravel

I disable "only_full_group_by" on mysql but "laravel" giving above error
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'answer_reactions.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select * from `answer_reactions` where `answer_reactions`.`answer_id` in (147, 156, 165) group by `answer_reactions`.`type`)

in Laravel config\database.php file, inside the mysql driver array add 'strict' => false, and give it a try.

Test with:
GLOBAL sql_mode=(SELECT REPLACE(##sql_mode,'ONLY_FULL_GROUP_BY',''));

Related

Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguous

$banks_transactions = DB::table('finance_banking_transactions')
->join('finance_banks', 'finance_banking_transactions.bank_id', "=", 'finance_banks.id')
->latest()->paginate(20);
How do i solve the error SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguous (SQL: select * from `finance_banking_transactions` inner join `finance_banks` on `finance_banking_transactions`.`bank_id` = `finance_banks`.`id` order by `created_at` desc limit 20 offset 0)" and I have the column
Because you use join, you need to specify latest().
for example, latest('finance_banking_transactions.created_at'), or instead using latest(), you can use orderBy('finance_banking_transactions.created_at')

Migration error when using jSON field on MariaDB

After trying to add a new jSon column to my Users table, I am getting an error related to field size. I blame MariaDB because they can't see the future, but is there a way to override this error without changing my field type to BLOB or TEXT?
Here is my up method in the migration:
public function up(){
Schema::table( 'users', function( Blueprint $table ){
$table->json( 'options' )->nullable();
} );
}
This is the error I get:
In Connection.php line 669:
SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large. The maximum row siz
e for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check t
he manual. You have to change some columns to TEXT or BLOBs (SQL: alter table `users` add `opti
ons` json null)
In PDOStatement.php line 129:
SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large. The maximum row siz
e for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check t
he manual. You have to change some columns to TEXT or BLOBs
In PDOStatement.php line 127:
SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large. The maximum row siz
e for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check t
he manual. You have to change some columns to TEXT or BLOBs

Laravel Eloquent Update Error

I am trying to update a row with eloquent in laravel 5.5 but i get this error.
In Connection.php line 664:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1769888, `longitud` = -8,4700727 where `id` = '7'' at line 1 (SQL: update `centro` set `updated_at` = 2018-02-19 15:58:01, `latitud` = 43,1769888, `longitud` = -8,4700727 where `id` = 7)
In PDOStatement.php line 107:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1769888, `longitud` = -8,4700727 where `id` = '7'' at line 1
In PDOStatement.php line 105:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1769888, `longitud` = -8,4700727 where `id` = '7'' at line 1

Advantage Database Server 8.1 UNIQUE CONSTRAINT multiple columns

I am working on an Advantage Database Server 8.1 and I have created a new table. I want to add a unique constraint for the combination of 2 columns.
I tried
ALTER TABLE TableName
ADD CONSTRAINT ConstraintName
UNIQUE (ColumnName1, ColumnName2)
but I get the error
"ERROR IN SCRIPT: poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2115; [Extended Systems][Advantage SQL Engine]Expected lexical element not found: You are missing the column names. -- Location of error in the SQL
statement is: 33 (line: 2 column: 5)"
Ok the solution I found is:
CREATE UNIQUE INDEX ConstraintName ON TableName (ColumnName1, ColumnName2);

laravel framework webservice error

I am just doing web service for laravel framework, so below error is displayed, I don't know which type of error
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'city' in where clause is ambiguous (SQL: SELECT MIN(room_prize)MIN,MAX(room_prize)MAX from `abserve_hotel_rooms` as `ar` JOIN `abserve_hotels` as `h` ON `ar`.`hotel_id` = `h`.`hotel_id` WHERE 1 AND `city` ="madurai" AND `country` ="india")
You forgot table alias to the fields city and country

Resources