MySQL ServerSponsored by Jamf Now

47K

Solutions

22K

Contributors

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.

Share tech news, updates, or what's on your mind.

Sign up to Post

Good morning, does anyone know if its possible to update a mysql date field to the last day of previous month? I can grab the new date in a select but cant figure out how to update?

SELECT
  paid,
  date_paid As 'Old PayDate',
  Last_Day(date_paid - INTERVAL 1 MONTH) AS 'New PayDate'
FROM
  tbl_invoice
WHERE
  paid = 1

Open in new window


This obviously doesnt work but if anyone knows a method would appreciate it.
UPDATE  tbl_invoice
SET     Last_Day(date_paid - INTERVAL 1 MONTH)

Open in new window

0
Cloud Class® Course: Microsoft Azure 2017
LVL 12
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Hi,

I am curious about best practices

Scenario:
Want to be able to track group task and personal tasks

Details
  1. Group tasks are independent of personal tasks
  2. Group tasks can be assigned to a person
  3. Task assignments are only at the group level
  4. Personal tasks are automatically assigned to that user
  5. Personal tasks only apply to that person
  6. The columns within the tasks table would be identical for both personal and group with exception of the ID (group/user)

Im curious if it is better practice to great three tables like so

tables
  1. entity type (ex: 1 =  group, 2 = user)
  2. tasks -> add an additional field to compensate for entity type
  3. tasks-assignments

Or to separate the tasks table into two tables one for users and one for groups (assignments would only be associated to the second table)

Thanks in advance!!
0
Hi Experts

Could you point how to present and validate a combobox value by using CakePHP?

Accordingly to:
Data Model  - There's a FK from Usuarios table to Posts table
img002
The page's layout
 img004
View's code: add_with_validation.ctp
  <div class="posts form">
<p>
	This form is like the first one but here we validate that a post must have
	at least one tag.
</p>
<?php echo $this->Form->create('Post'); ?>
	<fieldset>
		<legend><?php echo __('Add Post validating the number of tags'); ?></legend>
	<?php
		echo $this->Form->input('name');
        
        // Tags correctly presented    
        echo $this->Form->input('Post.Tag',array('label'=>'At least one Tag', 'type'=>'select', 'multiple'=>true));
	
        
        //Code to present the Users combo (what I need to be done)
		echo $this->Form->input('Post.Usuario',array('label'=>'At least one Usuario', 'type'=>'select', 'multiple'=>true));
	?>
	</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
	<h3><?php echo __('Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__('List Posts'), array('action' => 'index')); ?></li>
	</ul>
</div>

Open in new window


The correspondent controller's code
  public function add_with_validation() {
    if ($this->request->is('post')) {
      $this->Post->create();
      if ($this->Post->save($this->request->data)) {
        $this->Session->setFlash(__('The post has been saved'));
        return $this->redirect(array('action' => 'index'));
      } else {
        $this->Session->setFlash(__('The post could not be saved. Please, try again.'));
      }
      
    }
    $tags = $this->Post->Tag->find('list');
    $this->set(compact('tags'));
// I guess something must to be done here to consider "usuarios" - my tryes resulter in errors...

  }

Open in new window



Model's code
<?php
	
  App::uses('AppModel', 'Model');
/**
 * Post Model
 *
 * @property Tag $Tag
 */
class Post extends AppModel {

/**
 * Display field
 *
 * @var string
 */
  public $displayField = 'name';

/**
 * Validation rules
 *
 * @var array
 */
  public $validate = array(
    'name' => array(
      'notempty' => array(
        'rule' => array('notBlank'),
      ),
    ),
    
    // My Try to validate the usuario combo contents

        'Usuario' => array(
        'multiple' => array(
        'rule' => array('multiple', array('min' => 1)),
        'message' => 'You need to select at least one tag',
        'required' => true,
      ),
    ),
    
    'Tag' => array(
      'multiple' => array(
        'rule' => array('multiple', array('min' => 1)),
        'message' => 'You need to select at least one tag',
        'required' => true,
      ),
    ),
  );

Open in new window


Thanks in advance!
0
How can i alter a stored procedure so that the Timestamp column enters current date and time in mysql?

My stored procedure takes data from a form input and inserts it into a table, it has a timetamp field generated by the server which is  passed to mysql,  but i want the database to use the NOW() function instead to generate the timestamp.

my stored procedure:
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_Data`(
       eCard longtext,
      _Timestamp datetime,
      Registration varchar(200),
    `Name` varchar(200))
BEGIN
      declare cID varchar(100);
      

    SELECT cID = `ClientID`  FROM `Clients`  where `Key` = eCard limit 1;

insert into Forms (
        `ClientID`
      ,`Key`
      ,'Timestamp'
      ,'Registration'
      ,`Name`
        )
        values
        (
        cID
        ,eCard,
       ,NOW() ----------> Here?
       ,Registration
       ,Name
          );
        
END

Where do i place the NOW() function ?
0
Can someone please explain the point of NULL in database tables?

I have the option to set a field to be NULL if it is blank. Why would i do this, instead of just leaving it blank?
0
Hi there.

I'm still working on a conversion of a MySQL based web database to MS SQL Server, and I have a little issue. In MySQL I could save NULL to a date variable, and it would show nothing in the web interface and back-end. But in MS SQL if I save a NULL (simply no value - NULL allowed) is still saves the date 01-01-1900. Is it possible to avoid that? If no date is saved, nothing should show up.
I use asp/VB.

Best regards

Ulrich
0
string query = string.Format("SELECT Month(P.Payment_date)Month,COUNT(*)Volume,SUM(P.amount)Collection FROM carpark_db.payment P,carpark_db.transaction T WHERE P.transaction_id = T.transaction_id AND P.carpark_id = 'AMYDE5E27D5846D0B3F3A8BA4CA4C127' and year(payment_date) =  '2017' GROUP BY Month ASC");

It takes time to retrieve data from DB and gave 300 Seconds in command timeout  but still getting error

 MySql.Data.MySqlClient.MySqlException: 'Fatal error encountered during command execution.'MySql.Data.MySqlClient.MySqlException
  HResult=0x80004005
  Message=Fatal error encountered during command execution.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>Inner Exception 1:MySqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.


Please tell me how to fast retrieve data from database and displays it in web page.If it is  monthly or yearly report takes time for calculations (sum,count) to retrieve data from DB  .
0
Hi,

MySQL is Failing to start the service due to the following Error. Is there a way to fix this table:

InnoDB: Attempted to open a previously opened tablespace. Previous tablespace mysql/innodb_index_stats uses space ID: 2 at filepath: .\mysql\innodb_index_stats.ibd. Cannot open tablespace webgroup/area which uses space ID: 2 at filepath: .\webgroup\area.ibd
0
Get a hourly based report for count the number of vehicles traveling on that particular hour(0-23 hour) in MYSQL .
If there is no vehicles traveled on that hour,supposed to be displayed 0 , otherwise it will give count the no of vehicles travelled.

MySQL Query is displayed only the vehicles entered hour only
        SELECT Extract(hour from payment_date_time)Hour,Count(amount)Volume,sum(amount)Amount from carpark_db.payment where carpark_id ='AMSDE5E27D5846D0B3F3A8BA4CA4C127' and payment_date_time >= '2018-01-02 00:00:00' and payment_date_time < '2018-01-02 23:59:59' group by extract(hour from payment_date_time) order by extract(hour from payment_date_time

plz help me
0
Hi Expert,

I'm Looking for MySql DB Backup process in a Linux Machine which i want to schedule by crontab in a with every 3 days window duration.

Could anybody can guide me for basic shell steps and the back up steps .

Please let me know if there any additional information .

Thanks in Advance!
0
Cloud Class® Course: C++ 11 Fundamentals
LVL 12
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Hi there, hoping this is possible but unsure so thought Id ask. The below code sends an email to a hardcoded email address but I wondered if its possible to have it send instead to the field in this query 'u.emailaddress', I am using sendmail..

            $sql = "SELECT l.id, c.Adviser, c.ClientName, l.LeadStatus, l.CompDate, u.emailaddress
            FROM  tbl_lead l
            INNER JOIN tbl_clients c ON c.client_id = l.client_id
            INNER JOIN tbl_users u ON c.Adviser = u.username
            WHERE id = {$rowData['id']}";
            
            $customerFullName = $this->GetConnection()->ExecScalarSQL($sql);            
            $messageSubject = 'Case Completed';                           
            $messageBody = "<p>Adviser case has completed:</p>";           
              
              //compose email body
              $messageBody = '<html><body>';
              $messageBody .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
              $messageBody .= "<tr style='background: #eee;'><td><strong>Adviser:</strong> </td><td>{$rowData['Adviser']}</td></tr>";
</td><td></td></tr>";
              $messageBody .= "</table>";
              $messageBody .= "</body></html>";
              
              //end email body
              
            $address = 'u.emailaddress';
            $cc = array('useremail2', 'myemail@:domain.co.uk'); 
              
            try {
                sendMailMessage($address, 

Open in new window

0
Hi ,

Please Give me Solution for my Below Issue,

Got Issue like The OLE DB provider "MSDASQL" for linked server "MYSQLDB" reported an error. The provider ran out of memory.
0
hi,

how MySQL natively work with Monogo DB?

built in feature ?
0
hi,

what MySQL BI and report it offer ?

third party like MariaDB?

1) Power BI.

2) any other BI tools whose MySQL connector is compatible with MariaDB Server / ColumnStore.

3) Tableau
?
0
hi,

what kind of OLTP and OLAP solution MySQL has ?

please share URL.
0
hi,

Any graphic data modelling MySQL can offer ?
0
hi,

does MySQL after bought by oracle, has its own cloud server? any URL for it ?
0
hi,

any ASM like service MySQL can offer?
0
hi,

is there any chances that if we are using MySQL / MariaDB, if someone login using root account, he/she can delete any files in MySQL and Maria on the fly?
0
Upgrade your Question Security!
LVL 12
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Hi,

What encryption MySQL and MariaDB offer? MySQL offer the same as MariaDB ?

Encryption is on  the whole disk level or DB level only ? row level or database file level?
1
hi,

how can MySQL work with / load and save data from Hadoop ? any build in tools for it ?

is it scalable solution ?
0
hi,

every oracle DBA knows there is a product called ASM, is there anything like this for MySQL ?
0
hi,

for MySQL , any feature/way to move all MySQL DB files on RAM , not just logical table / objects?
0
I'm trying to drop a database from PHPmyadmin but the option is not enabled. I googled and it says you have to change some values on config.inc.php.
 I just can't find the config.inc.php file. I'm supposed to login through a program or something?
0
Moving a Wordpress eCommerce Site.

I'm moving a WordPress / WooCommerce site.  Thousands of products, DB in excess of a gig, 100K visitors a month.
They are interested in Cost comparison between:
1. GoDaddy
2. Bluehost
3. WPEngine
I'm going to go through the due diligence of putting those numbers together.  BUT from a developer standpoint which, in your opinion,  is the best hosting choice and why?  The hosting company does not have to be on this list and the hosting company does not need to be the least expensive.  What company(ies) do you feel are the best in service, hardware, security,, etc...  Thanks in advance.
0

MySQL ServerSponsored by Jamf Now

47K

Solutions

22K

Contributors

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.