MySQL Server





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

        $query6 = $conn->prepare("SELECT sup_contact, radnew FROM support WHERE sup_contact = 'Bill' AND radnew='New Ticket' ");
        $results6 = $query6->get_result();
     $row_cnt6 = $results6->num_rows;

Open in new window

The above code works but I need to be able to use the code to return a row count for radnew='In Progress', radnew='Closed' and radnew='No Category' as some sort of loop rather than writing it out 3 more times for the other variables

Also, is it possible to use this:
$variablename = $_GET['variable1'].$_GET['variable2'].etc
As a string
IT Pros Agree: AI and Machine Learning Key
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

            $query = $conn->prepare("SELECT sup_id, sup_ticketnumber, sup_company, sup_contact, sup_email, sup_phone, sup_rep, sup_comments, sup_addcom1, sup_addcom2, sup_addcom3, sup_editcom1, sup_editcom2, sup_editcom3, sup_todo, sup_timefrom,  sup_timeto,  sup_date,  radnew, radinprogress, radclosed, radnocategory, chkemail, chkphone, chksms, chkproject FROM support ORDER BY sup_date asc");
            $results = $query->get_result();
I need to echo out the sum of the sup_id column
Help please

Open in new window

This is related to MySQL.
I ran a command --> mysqldump -u -p DBNAME > [Path of .sql file],
After running this command , I ran --> mysql -u -p DBNAME > [Path of .sql file].
After this, my Table data got overwritten and my Table is blank. Only the table structure remains. Please suggest how to bring back the Table original Data.
I'm trying to select the data from the most recent date/year in a table. For example, I have the following data:

countyID   | datadate   | dataPercentage
1             | 2015          | 54
2             | 2015          | 60
3             | 2015          | 51
1             | 2016          | 54
2             | 2016          | 59
3             | 2016          | 53
1             | 2017          | 56
2             | 2017          | 64
3             | 2017          | 59
1             | 2018          | 56
2             | 2018          | 72
3             | 2018          | 57

Open in new window

I want to get the result:
1             | 2018          | 56
2             | 2018          | 72
3             | 2018          | 57

Open in new window

From what I've read, I got the impression the following query would work:
SELECT countyID, dataPercentage, MAX(dataDate) 
FROM myTable

Open in new window

But that returns the first set of percentages (from 2015) with the most recent date.
1             | 2018          | 54
2             | 2018          | 60
3             | 2018          | 51

Open in new window

What am I doing wrong and what should I be doing instead? Thanks!
I have a MySQL table called 'projects'. I want to copy it to another brand new table called selections.

I exported the table 'projects' , edited it with Notepad to change 'projects' everywhere to 'selections'.

Tried to load it, didn't work.

What is the correct was to do this.

How do I create a MySQL dump command line that ignores views, stored procs, triggers, everything except tables and table data? All I want to transfer from one db on a server to another db on a different server is table /drop /create and table data.
Dear Experts, I use PHP and mysql.

I'd like to select distinct voters from my table. Some of my users have voted more than once.

if user voted more than once, I'd like the get the latest answer.

how can I select distinct uid and answer column from my table with the latest vote?

how can I select the later vote? I want to select the last insert.

(I have an autoincrement id column on my table. )

I wrote it like this? is this correct?

SELECT DISTINCT uid,answer,city FROM mytable order by id DESC
Hello Experts!

the following Mysql command:

 UPDATE TBL_TREATMENTS SET PAT_COD = 1 , tre_des = "<old pat:2* Mrg:1>" + TRIM(tre_des) WHERE PAT_COD = 2

is giving me the error message:

Error Code: 1292. Truncated incorrect INTEGER value: '<old pat:2* Mrg:1>'

but when executing from workbench it works!
Why is this and how can I solve it?
Dear Experts,
I use PHP and mysql,
I want to select the details and the total from my siparis list with the one sql sentence however, there is an error.
Although there is a coloumn named _key it gives the below error.
what do you suggest I should do?

#1054 - Unknown column 'g._key' in 'on clause'

  , t.uid
  , t.bayiadi
  , t.adet
  , t.toplamtutar
FROM siparis t
          , uid
          , bayiadi
          , SUM( toplamtutar ) AS Total
        FROM siparis g
        GROUP BY
          , uid
          , bayiadi
    ) sq ON t._key = g._key
        AND t.uid = g.uid
        AND t.bayiadi = g.bayiadi
WHERE MONTH( t.tarih ) = 12
AND YEAR( t.tarih ) = 2018
AND t.uid = 'xxxxxxxx'
AND t.gecerli = '1'
   t. _key DESC
Dear Experts,
I use PHP and mysql.

I want to select data from my table with one sql sentence.

how can I select the data and the sum of the data with the same sql sentence?

I want to select sum(number) as total also with the below sql sentence? How can I do that?
when I added to the sql sentence it gives me only one row, althoug the result must be more than one row..

SELECT _key,user,name,number,FROM mytable where month(tarih)='12' and year(tarih)=2018 and user='xxxx' and valid='1' order by _key DESC

thank you
Protecting & Securing Your Critical Data
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

We have been importing Epicor parts and purchase order data (Clients ERP system) for a few years now by using an MS Access queries via ODBC connections to isolate the needed data from Epicor and then populate a temporary MS Access table that is only used to support the import query process that runs on a two minute timer .  Then we are using MS Access queries and ODBC connections to move any new records needed into a MySQL database.  This has been working fine until recently the client consolidated two other locations into the Epicor system, so now USA, Canada, and Germany are all now working off of the same Epicor database.  Since that happened my 50 character text field in the MS Access table looks like it has a part number as:


When I run the append query to add it to MySQL, it ends up as:


The part description filed in MS Access contains some spaces and some additional lines :

RES SMD 1K OHM 1% 1/8W 0805

And ends up in MySQL as:

RES SMD 1K OHM 1% 1/8W 0805

I've been trying all manner of strategies to either prevent the question marks from being added, or running an update query to replace them but the following update query simply deletes the entire record instead of just getting rid of the question marks.

SET tbl_bom.PartOurNumber = REPLACE (PartOurNumber, "?", "")
WHERE tbl_bom.PartOurNumber LIKE "%?%"

Open in new window

I'm hoping …
 <?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_new = $row['radnew'];
       $data_progress = $row['radinprogress'];
        $data_closed = $row['radclosed'];
if (isset ($row['radnew'])) {
    $style2 = "style='background:#ddd000;'";
      else if (isset ($row['radinprogress'])){
    $style3 = "style='background:#FFa500;'";
         else if (isset ($row['radclosed'])){
    $style4 = "style='background:rgb(255,100,0);'";

                <table id="customers">
                  <th>Ticket Status:</th>
                     <th>Ticket Status:</th>
                     <th>Ticket Status:</th>
                        <td><?= $row['sup_id'] ?>&nbsp;<?php echo "<a href=\"searchWorkformSitesDateStatus.php?id=" . $row['sup_id'] ."\" target=\"_blank\">RecordLink... </a>"; ?></td>
                        <td><?= $row['sup_company'] ?></td>
                        <td><?= $row['sup_contact'] ?></td>
                        <td <?php echo $style2 ?>><?= 

Open in new window

MySQL form POST to database.  When INSERT INTO query is performed on what seems are random basis (or perhaps it is based on content of the data POSTed from the text area on the from, the data saved to the field in the database sometimes has duplicate information.  For example, if there are multiple sentences, a portion of one of the sentences will be duplicated in the paragraph of text.  Not sure what would cause something like this.  When using the form we can edit and try to save the same text several times, usually it will eventually save correctly.  I have several other application/database pairs on the same web/mysql server and don't seem to experience this issue.  So I am assuming the problem is coming from this specific website.

Here are some code snippets:

from the PHP form:

<div id="workOrderForm">
                              <form name="workOrderForm" method="post"  action="formdata.php">
                                       <div class="formLable">Client Code:</div>
                                       <input name="clientCode" type="text" class="formFiller" onkeypress="return disableEnterKey(event)" option value="<?php echo $result['clientCode'];?> "  />
                                    <div id="emailLable">Email:</div>
                                       <input name="email" type="text" id="emailFiller" onkeypress="return disableEnterKey(event)" option value="<?php echo $result['email'];?>" />
                                    <div class="formLable">Company Name:</div>
                                       <input name="companyName" type="text" class="formFiller" onkeypress="return …
Query takes longer time to fetch the records :

SELECT rptmtc.panelID AS panelID, CAST(rptmtc.nGradeID as UNSIGNED INTEGER) AS ReportGrade
, tmtcremarklogid.nMTCID AS nMTCID, mmtcremark.sRemark AS sRemark, CAST(mmtcremark.nGradeID as UNSIGNED INTEGER) AS RemarkGrade 
FROM ((rptmtc INNER JOIN tmtcremarklogid ON (((rptmtc.nMTCID = tmtcremarklogid.nMTCID) AND (rptmtc.panelID = tmtcremarklogid.sItemButtonID)))) 
INNER JOIN mmtcremark ON ((tmtcremarklogid.nMTCRemarkID = mmtcremark.nMTCRemarkID))) 
where rptmtc.nMTCID = 35 GROUP BY rptmtc.nMTCID, rptmtc.panelID, tmtcremarklogid.nMTCRemarkLogID

Open in new window

FYI, the query returns total 14 Rows (and time is 164.500 sec)

D Patel
If there is no permission to database how to get the event log.

I have the following mssql code that I need converted into mysql code because I do not have mssql 2008 and above.  I have been reading about the insert function in mysql but I have no idea now to convert the stuff code to that.  Any help would be greatly appreciated.  Thank you in advance.
select lname
       , cert
       , STUFF((select ', ' + certExpDate 
                  from hubspot_list b 
                 where b.grad_id = a.grad_id
                 for xml path('')), 1, 2, '') as certExpDate
       , certname
    from hubspot_list a
group by lname)

Open in new window

Hello experts,

There is an issue in printing records in sub-report. I have explained my query in detail in attached file.

Please help.

D Patel
This is not really a problem - yet. It is merely me trying to understand how to secure my code from sql injection. I'm using classic asp as it's all I know.

As far as I understand using stored procedures within my mysql database and then  calling these procedures would be the way forward. I'd like to get this working.
I was directed towards this web-page in an earlier question:

However this concerns an MS access database, and I can't get it to work in my mysql database (for obvious reasons I guess).

Let's assume that I have table MyTable with the followong fields: Id (mediumint), GUID (varchar), Name (Text), DateInserted (Datetime), Comments (Text) (DateTime), Status (mediumint)

I need to read from, update, insert and delete in this table.
I would need to create stored procedures for this, right? I can't seem to find a way to do that using phpMydAdmin (which is what I got and will use, regardless). How would I create these procedures?

Remember that this has to work with classic asp.
Best regards
Dear Experts,

with below code I select the data from my table and show it on the google maps.

my link is like this: xml.php?birinci=2018-12-12&ikinci=2018-12-29&satisci=me
this link works perfectly fine

however this link is not bringing any data althoug there is data.

I don't understand why it is not working with diffrent date? what do you think I should do?

my code is below

$birinci= $_GET["birinci"];
$ikinci= $_GET["ikinci"];
$satisci= $_GET["satisci"];

$birinci = date("Y-m-d", strtotime($birinci));
$ikinci = date("Y-m-d", strtotime($ikinci));




$mysqli->query("set names utf8mb4");

$sql = "SELECT * FROM mytable WHERE tarih between '$birinci' AND '$ikinci' AND uid='$satisci' and lat is not Null order by id asc ";

$res = $mysqli->query($sql);

$xml = new XMLWriter();



while ($row = mysqli_fetch_assoc($res)) {

 $xml->writeAttribute('id', $row['id']);
  $xml->writeAttribute('name', $row['adi']);
 $xml->writeAttribute('address', $row['tarih']);
  $xml->writeAttribute('lat', $row['lat']);
  $xml->writeAttribute('lng', $row['lng']);
  $xml->writeAttribute('type', $row['bayikodu']);

Open in new window

Learn Ruby Fundamentals
LVL 12
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Hi,  I'm creating a PHP and MySQL web application for a client. I'm a fairly new web developer.
Is there a way to add page titles and meta tags dynamically? It's a small application. I'm not using a Framework.
I saw a couple of possible solutions on google, but am not sure what the easiest and most efficient way of doing it would be.

Possible Solution #1, add variables in my header.php page and then on each respective page for example about, contact etc... add those variables above the include statement.
Here is my header.php code:


<!DOCTYPE html>
<html lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="<?php echo $meta_description; ?>">
	<meta name="author" content="Ryan Sacks">
	<link rel="icon" href="img/favicon.ico">
	<title><?php echo $page_title; ?></title>
	<!-- Bootstrap core CSS -->
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<!-- Font Awesome Icons -->
	<link rel="stylesheet" href="" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
	<!-- Custom CSS -->
	<link href="css/style.css?v=<?php echo time(); ?>" rel="stylesheet">
	<!-- Google Fonts -->
	<link href=",400,500" rel="stylesheet">

Open in new window

I am bound in this project to using mysql.
My problem is I've never had to use "count" in a join, and there must be a better way to do this because it is taking an incredibly long time.
The query is
   $Q = "FROM AccountsMain INNER JOIN PricingMain2 ON PricingMain2.AppID = AccountsMain.AppID
            WHERE PricingMain2.Status != 'Limbo' AND PricingMain2.Status != 'Deleted' AND PricingMain2.ModifyDate > '$RecordDate'";

Open in new window

I then do this to get the total count for pagination
   $Result = mysql_query("SELECT count(*) ".$Q;
   if(!$Result){$Error[] = "Database Failure [1]";}
      $query_data = mysql_fetch_row($Result);
      $TotalCount = $query_data[0];

Open in new window

Then this
   $GSReq = "AccountsMain.AcctName"; 
   $Limit = 'LIMIT '.($PageNo - 1) * $PageSize.','.$PageSize;
   $TotalPages = ceil($TotalCount/$PageSize);
   $Query = "SELECT * ".$Q." ORDER BY ".$GSReq." ".$Limit;

Open in new window

This process takes almost 60 seconds on a mere 10,000 records.
I have a problem updating a mysql table entry.  I copied and pasted the format I've used for years to update tables, but for some reason it is not working here.

My query reads, $queryUpdate1=mysql_query("UPDATE material SET _3Quan = '$_3Quan' WHERE file='$file'") or die('Query failed1: '.mysql_error());

The variable $_3Quan has a value of 100, but when the material table is updated, it returns a value of 0 to the _3Quan field.  Prior to update the value was 95.

Can you help me figure out what I'm doing wrong here?
Does the MySQL/MariaDB RAND() function take an argument, and if it does, what does it do?

I've tried entering numbers and it still just gives me a number between 0 and 1.
I would like to update fields in an existing group the custom fields in WordPress more quickly  in a "BATCH form" did anyone here mange to do it without messing up.
for example I want to start with adding extra text fields to an existing group,
Maybe MYSQL request ?
Maybe JSON request.
has anyone done this ?
Hi EE,

I have just installed xampp with the Apache and MySQL services installed.

When I am to reset the Mysql Server username/password but I go to phpmyadmin I am getting the following error message (see attached).

Attached are the config files for Apache and MySQL as well.

Any assistance is welcome.

Thank you.

MySQL Server





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.