Posts

Showing posts from August, 2017

How do I detect a duplicate row in database table with sql?

  i want to detect the duplicate columns of database table. the sql is given below:  select column_name, count( column_name ) as number_of_occurrences from table_name Group_by column_name Having(count( column_name )>1) limit 0,100 SELECT   MemberId ,   COUNT (   MemberId   )   AS   NumOccurrences FROM   members GROUP   BY   MemberId HAVING   ( COUNT (   MemberId   )   > 1 ) LIMIT   0   ,   238

Failed to run query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'MoneyMethod' cannot be null

 The 'field name' in form and the column name of database was different. My problem was:       "Integrity constraint violation: 1048 Column 'MoneyMethod' cannot be null". My form input tag:   {!! Form::select("MoneyMethod", $MoneymethodInfo, null,["class"=>"form-control MoneyMethod required","id"=>"MoneyMethod"]) !!} Nnotice the spelling of 'MoneyMethod' and in my database table $table->string('MoneyMethod', 100);  the spelling of 'MoneyMethod' is same as form but in my controller $riskfund->Moneymethod  = Input::get('Moneymethod'); look carefully the spelling of 'Moneymethod' differs from my form and database table column. After correcting the spelling, it is working now. So, please check the spelling of the spelling of the field  in form, controller, database table for which you are facing the problem. it may help you.

How do i increase a column of a table using Laravel 5?

It's very simple to increment an specific column of a table using laravel.  Conditions: The specific column's data type should be an 'int' type. procedures:                    1. Link your app model to your linking section with this code                           use App\ Loanapplication ;                    2. then just write the following codes to increment your specific database column                           $loanapplication = Loanapplication::where('MemberId', $MemberId)->increment('PayedInstallment');        ...