[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

MySQL Server

47K

Solutions

23K

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

  <?php if ( ! isset($_GET["company"]) ): ?>

            <p>No Company Info has been passed in!</p>

        <?php else: ?>

            <?php
            // Let's run the query
            $query = $conn->prepare("SELECT frm_id, frm_companyname, frm_contact, frm_email, frm_rep, frm_date, frm_return, frm_timefrom, frm_timeto, frm_comment1, frm_comment2, frm_comment3, frm_comment4, frm_comment5, frm_todo1, frm_todo2,  frm_todo3,  frm_todo4,  frm_todo5, frm_updated  FROM siteform WHERE frm_companyname = ?");
            $query->bind_param("s", $_GET['company']);
            $query->execute();
            $results = $query->get_result();
            ?>
     
            <?php while ($row = $results->fetch_assoc()):$style = "";
  //if ($row['frm_id'] < "5"){
    //$style2 = "style='background:#FF0000;'";
  //} 
                  
  //if ($row['frm_id'] > "5"){
    //$style2 = "style='background:#FFF000;'";
  //} 
         //if ($row['frm_id'] =="5"){
    //$style2 = "style='background:#ddd000;'";
  //} 
       $data_db = $row['frm_date'];
       $current_date = date('Y-m-d', strtotime(" Today"));
        $current_date2 = date('Y-m-d', strtotime(" -1 month"));
        $current_date3 = date('Y-m-d', strtotime(" -2 month"));
        $current_date4 = date('Y-m-d', strtotime(" +1 day"));
        $current_date5 = date('Y-m-d', strtotime(" +1 month"));
         $current_date6 = date('Y-m-d', strtotime(" +2 month"));
    
if ($data_db == $current_date){
    $style = 

Open in new window

0
Amazon Web Services
LVL 12
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

How can I turn a single row of 15 columns into 15 rows with 2 columns for ORDER BY?

I have an online form and the SQL to score the form data we have puts everything in a single row. What we need is 15 rows so we can use ORDER BY. I have googled PIVOT mySQL, but that is the opposite of what I want.

What I am doing is summing multiple rows per column from a ninja form:

SELECT  SUM(ACCEPTANCE) as ACCEPTANCE, 
        SUM(ASSOCIATION) as ASSOCIATION, 
        SUM(CURIOSITY) as CURIOSITY,
        SUM(EGO) as EGO, 
        SUM(EMPATHY) as EMPATHY, 
        SUM(ENVY) as ENVY, 
        SUM(EXCITEMENT) as EXCITEMENT, 
        SUM(FAMILY) as FAMILY, 
        SUM(FEAR) as FEAR, 
        SUM(GREED) as GREED, 
        SUM(HUMOR) as HUMOR, 
        SUM(HUNGER) as HUNGER, 
        SUM(LAZY) as LAZY, 
        SUM(SEX) as SEX, 
        SUM(TRUST) as TRUST

FROM v_nf_questions q
JOIN v_nf_answers a on q.q_id=a.a_id
JOIN answers_table ans ON a.f_answer=ans.ARCH_NAME
WHERE nform_id = 348

Open in new window


So here is what I get
what_i_have.jpeg
But here is what I want
what_i_want.jpegwhat_i_have.jpeg
what_i_want.jpeg
0
Hello Experts,

I am having issue with .MYSQL file not updating in sync with a parent table class. The code is as following:

Create table Login
(Username varchar(15)NOT NULL,
Firstname char(10) NOT NULL,
Lastname char(10) NOT NULL,
Password varchar(15) NOT NULL,
email varchar(25) NOT NULL,
PRIMARY KEY(Username));

INSERT into Login VALUES ('jason44','Jason','Labor','12345','jason@gmail.com');
INSERT into Login VALUES ('carol39','carol','spice','qwerty','carol@gmail.com');
INSERT into Login VALUES ('jennifer89','jennifer','Cicco','asdfg','jennifer@gmail.com');
INSERT into Login VALUES ('michael27','michael','lutherl','0987654','luther@gmail.com');

Open in new window


This is the synced table below:

create table Historical
(OrderNumber int(100) auto_increment,
Username varchar(15)NOT NULL,
CustomerType char(6),
NumberTickets int(3),
TicketCost float(5,2),
CreditCard int(16),
PRIMARY KEY(OrderNumber),
FOREIGN KEY(Username)REFERENCES Login(Username)
);
INSERT into Historical VALUES (NULL,'jason','Adult',2,7.00,9876543);
INSERT into Historical VALUES (NULL,'carol87','Adult',1,7.00,9876543);
INSERT into Historical VALUES (NULL,'jennifer1234','Adult',3,7.00,1828288);
INSERT into Historical VALUES (NULL,'michael987','Child',2,7.00,1828288);

Open in new window


The  error is as follows:
"ERROR 1452: Cannot add or update a child row: a foreign key constraint fails"

When attempting to insert new rows or values into the child table, this error occurs. While the file runs, it cannot be made updates. I am currently using only the cmd line of MySQL for this issue.
0
I have a wp site that is working fine on my windows production server, site is called jobs.org ( as an example).  I was asked to create the same site on the dev server so I copied over the wp files and called site dev.jobs.org . The same mysql database is still being used.  When going on the dev site I am getting:

PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 1792 bytes) in \\******\SITES\dev\jobs.org\wp-includes\load.php on line 747

Can someone please explain what I am doing wrong? Is there some config change that has to be made? Is it necessary to create a second mysql database?

Thank you.
0
So I'm trying to work out the best table structure and how to interface with the data...

I want to store in a database a list of urls and "tag" them with multiple pre-defined keywords for me to search on later.  The tags on the urls may need to be updated from time to time. ie it's not a one off tagging but an on-going review of each URL.  More tags may be added in the future and I may need to go back to the urls to re-tag them.

I have the list of predefined tags/keywords in a table and I'm now trying to work out what the structure of the resultant table should be in order for it to be easy to update/add/remove the tags for any given url but also to be able to search for a url based on a keyword.

So far I have
tags table
ID | NAME
1 | medical
2 | karate
3 | Technical
4 | Javascript
5 | Shopping

For the resultant table, my initial structure:
URL & TAG_ID are a UNIQUE combination
ID | URL | TAG_ID
1 | www.e-e.com | 4
2 | www.e-e.com | 3
3 | www.google.com | 1
4 | www.google.com | 2
5 | www.amazon.com | 5

So you can see there's multiple entries for one url so that there's a one-to-one match with a tag.  I'm not sure if this is the best approach?

BTW The urls and tags given above are for example only and haven't determined the ones I'll use yet.  I'm more interested in the structure I would use.

If the above table structure is sound, then how do I go about adding/removing tags?  The server will receive a set of tags from the
0
Is it possible to restore a MySQL table from its .ibd file?
0
Need to find a php script to upload an csv file onto a server. If you have clean code that works, I would be happy to move onto partnering with a few projects. Really need a php, mysql website developer to help.
0
Hi'

I'm trying to load an inventory table from a mysql table that contains an enormous amount of table rows, so rather than load it all use a "where and like statement."

My statement looks like this: -
$CatID = isset($_POST['CatID']) ? $_POST['CatID'] : false;

$query = 'SELECT 	
partID, 
partDescription, 
qtyInStock
FROM inventory
WHERE partDescription like "%'.$CatID.'%" ';

Open in new window


The query works performing a wildcard search using the input of 'CatID' from a form that has the ID Tag: "CatID" but annoyingly only once it loaded the whole page to start with - what did I miss?
0
Hi,

as we found data type after convert from Oracle to MariaDB there are diff, I'd like to know:

1) does MySQL/MariaDB has DATE only type ? Why MariaDB use datetime? MariaDB only has datatime?
2)  Why varchar2(75) become TEXT
3) why varchar2(100) become TEXT

any information about what is the space occupied by both type ?
0
Migrating Oracle procedures which has JSON data as input and business validation to insert/ update/delete tables to MariaDB.

Can we use SQL_MODE to ORACLE and use the same procedure ? Or we need to rewrite it again.

Like few differences where we use JSON_PARSER.PARSER(<<my input JSON>>) or JSON_EXT.GET_NUMBER / JSON_EXT.GET_STRING in Oracle to get the values for specific keys. So can we directly use the same procedure to work on Mariadb by setting the mode or we need to rewrite the entire procedure.
0
10 Tips to Protect Your Business from Ransomware
LVL 1
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

I'm starting a new web development project and have decided on using PHP with the latest version of the Laravel framework (currently v5.7). I'll likely be deploying to AWS, and will be using Amazon Aurora as the database engine (which is supposed to be MySQL compatible).  As I prepare to dive in, a few questions have come to mind that I'm hoping someone here can answer.  I'm relatively new to the Laravel framework, I must say, so I a apologize in advance for my ignorance.

1) What options are available to me for setting up a local development environment under Windows 10 Home Edition (64-bit)?  So far, I've read about using Vagrant/Homestead, (which sounds complicated and like it might require Windows 10 Professional) -- and also using WAMP, which I already have installed and running on my machine. By any chance, does some kind of pre-configured Virtual Box disk image exist anywhere that I could download and install that would simplify things for me?  

2) Is there anything important that I need to keep in mind (that's not so obvious) regarding the supposed MySQL compatibility of Amazon's Aurora database engine as I'm developing and/or deploying?  Can I safely treat Amazon's Aurora as a normal MySQL database engine, or are there any "gotchas" that I should be aware of such as driver compatibility, etc?

3) What's the most current trend regarding which templating system to use with Laravel? I know that it comes with the Blade templating engine, and I've heard some …
0
Hi Experts!

Could you suggest the beter way to convert this json structure to a PHP array?

Sample: 
{
  "numeroGuia": "sample string 1",
  "paciente": {
    "nome": "sample string 1",
    "endereco": {
      "cep": "sample string 1",
      "logradouro": "sample string 2",
      "numero": 3,
      "complemento": "sample string 4",
      "bairro": "sample string 5",
      "cidade": "sample string 6"
    },
    "dataNascimento": "2018-10-22T17:53:58.4603585-03:00",
    "cpf": "sample string 2",
    "telefone": "sample string 3",
    "email": "sample string 4",
    "sexo": "sample string 5",
    "peso": 1.1,
    "convenio": 1,
    "plano": "sample string 6",
    "matricula": "sample string 7"
  },
  "contratante": {
    "tipo": 64,
    "contrato": 1
  },
  "atendimento": {
    "diagnostico": "sample string 1",
    "recurso": "sample string 2",
    "exames": "sample string 3",
    "carater": 64,
    "motivoAtendimento": "sample string 4",
    "cid": "sample string 5",
    "produto": "sample string 6"
  },
  "captacao": {
    "cor": "sample string 1",
    "dataInicio": "2018-10-22T17:53:58.4759589-03:00",
    "dataFim": "2018-10-22T17:53:58.4759589-03:00"
  },
  "origem": {
    "dataAgendadaChegadaOrigem": "2018-10-22T17:53:58.4759589-03:00",
    "nomeLocal": "sample string 1",
    "endereco": {
      "cep": "sample string 1",
      "logradouro": "sample string 2",
      "numero": 3,
      "complemento": "sample string 4",
      "bairro": "sample string 5",
      

Open in new window

0
Dear Experts,
I use PHP and MySql. My form is HTML5 form.
I post my form to another page to insert the form data inside mysql database.

I clean the form using this two functions.

function test_input($data) {
  $data = trim($data);
 $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
 	
   $comment = test_input($_POST["comment"]);
   $comment = $mysqli->real_escape_string($comment);
   
   // I clean every input with these two functions ( function test_input and real_escape_string )

My sql sentence is below
$sql = "INSERT INTO tvmakale (konu,resim,makale,tarih) VALUES ('$konu','$resim','$comment','$tarih') ";

Open in new window


the sql output is below. Because of the quotation marks, my insert sentence is not working.

INSERT INTO tvmakale (konu,resim,makale,tarih) VALUES ('Dubai\'s New Airport','new-airpor.jpg','CNN) — With more people than ever flying, cities around the world are building new airports and upgrading old terminals to create facilities capable of handling tens of millions of passengers. The results are modern, stylish architectural statements that banish the dark, crowded travel spaces of the past. Here are 16 of the most exciting airport projects under construction or redevelopment. Istanbul New Airport Turkey has great ambitions to become a new meeting point between east and west. Its national carrier, Turkish Airlines, already flies to more countries than any other airline globally, and with the prosaically named …
0
hi,

I am testing on Oracle to MariaDB convert tools and I need to setup DSN or ODBC connection, but other tools It only need Oracle sid/service name , username and password to convert.

so what is the format of DSN and ODBC string?

do I have to create one in Windows server?

setup-ODBC-or-DSN-connection.jpg
1
if (isset($_POST['company'])) {
$sql = "SELECT frm_id, frm_companyname, frm_contact, frm_email, frm_rep, frm_date, frm_return, frm_timefrom, frm_timeto, frm_comment1, frm_comment2, frm_comment3, frm_comment4, frm_comment5, frm_todo1, frm_todo2, frm_todo3, frm_todo4, frm_todo5, frm_updated FROM siteform WHERE frm_companyname = '$search'";
$result = $conn->query($sql);
                
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo '<div class = "divechoimages">'.'<a href="'. $link .$row["frm_id"].'">Create Individual PDF</a>'.$break.'<font color="blue">' . "id:" . '<font color="purple">' .$space.$row["frm_id"]. " - Company: " . $row["frm_companyname"]. $space."Contact: " . $row["frm_contact"]. $break." email: " . $row["frm_email"]. '<font color="red">'.$break." Rep: " . $row["frm_rep"]. '<font color="green">' .$break."Date Entered: " . $row["frm_date"]. '<font color="purple">' .$break."Return Date: " . $row["frm_return"]. $break."Time From: " . $row["frm_timefrom"]. $break."Time To: " . $row["frm_timeto"]. $break."Comment1: " . $row["frm_comment1"]. $break."Comment2: " . $row["frm_comment2"]. $break."Comment3: " . $row["frm_comment3"]. $break."Comment4: " . $row["frm_comment4"]. $break."Comment5: " . $row["frm_comment5"]. $break."ToDo1: " . $row["frm_todo1"]. $break."ToDo2: " . $row["frm_todo2"]. $break."ToDo3: " . $row["frm_todo3"]. $break."ToDo4: " . $row["frm_todo41"]. $break."ToDo5: " . 

Open in new window

0
Hello Experts,
I have a CSV file with 12 million lines. I am trying to upload it to a mysql table with the following command

LOAD DATA INFILE
 'c:\\_ms\\padron_reducido_ruc.txt'
 INTO TABLE tbl_padron_reducido
 FIELDS TERMINATED BY '|'
 LINES TERMINATED BY 'rn'
 IGNORE 1 LINES;

but I always get the message:

Error Code: 2013. Lost connection to MySQL server during query      30.000 sec

Why is this?

just in case he following variables, have those values.
SET GLOBAL interactive_timeout = 28800;
SET GLOBAL wait_timeout = 28800;
0
I need a calculated min column using datediff & min functions but not exactly the min value but the 2nd min value or date, below is the query for your reference:

Select r.rfq_Id, datediff(min(q.published_at),r.published_at) as "RFQ to 1st Quote TAT in days"

from quotes q
Left join rfqs r on r.id=q.rfq_id

This gives or groups me the rfq id column and date difference. But i want it use the 2nd min value for calculation rather than min value. Please suggest.
0
hi,

I am converting oracle table structure and data to mariaDB V10.3, using tools https://www.convert-in.com/oracle-to-mysql.htm, and the log say there are table can't be convert, let's see what it is:

1)
Table 'AQ$_QUEUES': column 'SUBSCRIBERS' has unsupported type 'AQ$_SUBSCRIBERS', skip it

2)
Table 'ROLLING$STATISTICS': column 'VALUEINT' has unsupported type 'INTERVAL DAY(3) TO SECOND(2)', skip it

3)
Table 'SCHEDULER_JOB_ARGS_TBL': column 'ANYDATA_VALUE' has unsupported type 'ANYDATA', skip it

4)
Table 'SCHEDULER_PROGRAM_ARGS_TBL': column 'DEFAULT_ANYDATA_VALUE' has unsupported type 'ANYDATA', skip it

is ANYDATA a customer defined type ? what type should it be when port to MariaDB ?

what type should this be : INTERVAL DAY(3) TO SECOND(2) when port to MariaDB ?
0
<?php
if(isset($_POST["submit"])){
$hostname='localhost';
$username='root';
$password='xxxxxxx';

try {
    $dbh = new PDO("mysql:host=$hostname;dbname=inventas",$username,$password);

    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line

 
$sql = "INSERT INTO inventassites (sites_name, sites_email, sites_company, sites_representative, sites_comments, sites_todo, sites_datevisited, sites_timefrom, sites_timeto, sites_return, sites_updated)
VALUES ('".$_POST["site_name"]."','".$_POST["site_email"]."','".$_POST["site_company"]."','".$_POST["site_rep"]."','".$_POST["site_comments"]."','".$_POST["site_todo"]."','".$_POST["site_visitdate"]."','".$_POST["time_from"]."','".$_POST["time_to"]."','".$_POST["site_return"]."','".$_POST["radvisit"]."')";

$sql2 = "INSERT INTO invhistory (histrepname)
VALUES ('".$_POST["site_rep"]."')";
if ($dbh->query($sql)) {
     echo "<script type= 'text/javascript'>alert('New Record Inserted Successfully');</script>";
} 
else{
     echo "<script type= 'text/javascript'>alert('Data not successfully Inserted.');</script>";
}

    $dbh = null;
    }
catch(PDOException $e)
    {
    echo $e->getMessage();
    }

}
?>

Open in new window


I am trying to insert data in to 2 tables at once but the second insertion does not work
0
Why Diversity in Tech Matters
LVL 12
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Hi i want to ask all expert about the confirmation number that is in the order such 1/2018 , 2/2018 , 3/2018 ... but mine confirmation  number is order by 139/2018 , 14/2018 .. Capture.PNGany solution for this ?
 
select * FROM church_info WHERE confirmation_date BETWEEN '".$start_date."' AND '".$end_date."'

Open in new window

my variable for confirmation number is  $row["confirmation_reg"]
0
Hi Experts,

I need help in writing an INNER JOIN between 2 values and casting.

Here are the tables
mysql> describe noc_careers;
+----------------+--------------+------+-----+---------+----------------+
| Field          | Type         | Null | Key | Default | Extra          |
+----------------+--------------+------+-----+---------+----------------+
| id             | int(11)      | NO   | PRI | NULL    | auto_increment |
| noc_code       | varchar(5)   | NO   |     | NULL    |                |
| noc_occupation | varchar(255) | NO   |     | NULL    |                |
+----------------+--------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)

mysql> describe noc_categories;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | int(11)      | NO   | PRI | NULL    | auto_increment |
| category   | varchar(255) | NO   |     | NULL    |                |
| range_from | smallint(6)  | NO   | MUL | NULL    |                |
| range_to   | smallint(6)  | NO   | MUL | NULL    |                |
+------------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)

mysql>

Open in new window


I need to return everything from noc_careers and the noc_categories.category. The relationship is where noc_careers.noc_code is within (>= noc_categories.range_from AND <= noc_categories.range_to).

To add to the complexity, note that noc_careers.noc_code is VARCHAR, so I also need to   cast it.

Any help will be greatly appreciated.
0
hi,

I am trying this tools ? http://www.sqlines.com/download: to try migrate tables and data from oracle 12c to mariaDB, but the downloaded SQL data tools binary always shows error:

when I test the connection to Oracle, it shows this error

SQLdata_Oracle.jpg
when I test the connection to MariaDB, it shows this error

SQLdata_MariadB.jpg
any idea on it ? come file missing ? how can I get it back?

the installation instruction of SQL data is :

How to Start:

  1. Download and unzip the file, no installation is required
  2. Run sqldataw.exe on Windows to launch the GUI version
  3. Run ./sqldata on Linux or sqldata.exe on Windows to launch the command line tool. Command Line Reference
  4. The tool uses low level native C/C++ connections and in-memory bulk loader APIs, so if you are able to connect to your databases using the existing client software, you should be able to start using SQLines Data immediately. SQLines Data Connections.

I do nothing wrong here.
0
Hi,
I would like some advice.
Recently I installed MYSQL V8 and I only work with Excel files which can be as large as 800 columns wide and up to 1 million rows.
Some time ago I had installed MYSQL for Excel which I managed to import a couple of files however I have since changed
computers and had overlooked that version.
Considering it took me a week or so to finally get this V8 working I am reluctant to uninstall and reinstall.
I did try to install the Excel version but cannot install over the existing installation.
My question is, is there a way to have both versions installed ? renaming folders etc ?
Thanks
Ian
0
Hi,

I am trying to connect to MYSQL but get attached error.
can you see anything wrong with the settings on attached png file ?
Thanks
Ian
localhost.png
0
Hello
EDITED 12th Oct 18
  • Summary
  • We have attempted to run Microsoft Azure Site Recovery (ASR) - Hyper-V Replication without success.
  • We are running Windows Server 2016 with 3 VMs
  • The ASR service has been installed by an external service company
  • We have been able to successfully complete the initial backup of the servers to the cloud
  • However the system  cannot keep up to date with the amount of changes on the server
  • All the upload bandwidth is being saturated (80 Mbps) and not keeping up with changes
  • (See attached screen shot of message from ASR)

These are the answers I received from the service company to my questions:
1. Could you tell me what the replication method we are using is called.
Azure Site Recovery - Hyper-V Replication
2. What the problem is. Is it the MySQL databases?
We don't know if it is the MySQL Databases for sure. As explained before the problem is too many changes are being made and the Azure servers cannot keep up with the constant changes.
3. Is the problem correctly described as being too much “data churn”?
I have forwarded the screenshot I had of the exact error message. (see uploaded image)

The service company cannot resolve the issue and say it is up to us to solve the data churn issue
They have asked Microsoft for help but they say they cannot because the issue is likely with …
0

MySQL Server

47K

Solutions

23K

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.