• Home
  • Tools
    • Color Chart
  • Software
    • Windows tricks
      • Windows 11 Speed Up Tricks
      • Windows Command Prompt CMD
    • Android Phone
      • Android – Dangerous Settings to Turn Off
    • Projects
      • Copy Files
      • Php Autoscript
      • Web Tools
  • Payments
  • Notes
  • System Tips

Notes

ACCESS 2022 | Browsers | Css | Htacess | Html | Html5 | Javascript | Microsoft Excel | Mysql | Mysql Dumps | Php | Vb.net | VBscript | Windows <=8 | Windows >=10 | WP | WP Plugin | WP Themes | _Misc Software |

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ON
PRT
OFF

<- Look Inside Data
Conditions:
Order:
15 Language Operation Title
Keywords
Application
Code Languageid
Show Html
Show Iframe
Make Public
Viewed
Viewed Date
Mysql Database Alter Table
change table alter table
Mysql



2
09/09/2023
Mysql Database Does Field Exit In Table
field exists
Developer
Mysql



0
12/02/2023
Mysql Database MySQL ALTER TABLE Statement
alter table drop add modify
ALTER TABLE prices
ADD COLUMN inventory smallint AFTER invoice;

ALTER TABLE eqMaintenance ADD COLUMN filter2id smallint AFTER filterid

ALTER TABLE filters ADD COLUMN model varchar(75) AFTER description
ALTER TABLE filters ADD COLUMN code varchar(10) AFTER model

ALTER TABLE filters ADD COLUMN cost decimal (10,2) AFTER type_of
ALTER TABLE fertilizer_applied ADD COLUMN crop_year smallint AFTER acres

=================================


increase size:
ALTER TABLE table_name MODIFY COLUMN column_name SMALLINT;
ALTER TABLE `bible` MODIFY COLUMN `chapter` SMALLINT;
ALTER TABLE `transactions` MODIFY `description` varchar (400);
ALTER TABLE `lastbackup` MODIFY `source` varchar (500);
ALTER TABLE `fertilizer_applied` MODIFY `comments` varchar (400);

ALTER TABLE `purchases` MODIFY `description` varchar (400);
ALTER TABLE `equipment_photo` MODIFY `caption` varchar (100);


MySQL ALTER TABLE Statement
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

The ALTER TABLE statement is also used to add and drop various constraints on an existing table.

ALTER TABLE - ADD Column
To add a column in a table, use the following syntax:

ALTER TABLE table_name
ADD column_name datatype;
The following SQL adds an "Email" column to the "Customers" table:

ExampleGet your own SQL Server
ALTER TABLE Customers
ADD Email varchar(255);
ALTER TABLE - DROP COLUMN
To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column):

ALTER TABLE table_name
DROP COLUMN column_name;
The following SQL deletes the "Email" column from the "Customers" table:

Example
ALTER TABLE Customers
DROP COLUMN Email;
ALTER TABLE - MODIFY COLUMN
To change the data type of a column in a table, use the following syntax:

ALTER TABLE table_name
MODIFY COLUMN column_name datatype;
Mysql



0
12/02/2023
Mysql Database Query Language
num show
Developer
1. Using the SHOW TABLES Command:

You can use the SHOW TABLES command to list all tables in a specific database and then check if your table is among them.

SHOW TABLES LIKE 'your_table_name';
Mysql



0
03/14/2025
Mysql Database Truncate A Table
empty truncate delete
Empty Tables
TRUNCATE TABLE parts

When you truncate a table, the AUTO_INCREMENT counters on the table will be reset.
MySQL truncates the table by dropping and creating the table. Thus, the DELETE triggers for the table do not fire during the truncation.
Starting in MySQL 5.5, you can not truncate an InnoDB table that is referenced by a foreign key in another table.
Starting in MySQL 5.6, you can not truncate a NDB table that is referenced by a foreign key in another table.

Example

In MySQL, truncating a table is a fast way to clear out records from a table if you don't need to worry about rolling back. In most cases, MySQL handles the process of table truncation a bit differently than other databases such as Oracle or SQL Server.

Let's look at an example of how to use the TRUNCATE TABLE statement in MySQL.

For example:

TRUNCATE TABLE customers;

This example would truncate the table called customers and remove all records from that table.

It would be equivalent to the following DELETE statement in MySQL:

DELETE FROM customers;

Both of these statements would result in all data from the customers table being deleted. The main difference between the two is that you can roll back the DELETE statement if you choose, but you can't roll back the TRUNCATE TABLE statement.

Let's look at one more example where we prefix the table name with the database name.

For example:
Mysql



0
03/31/2025
Mysql Database Using IF In Your Sql Statements
if query
Filtering By Formula
n MySQL, you can use the
IF() function to implement conditional logic directly within your SQL queries.
MySQL IF() function syntax:
sql

IF(condition, value_if_true, value_if_false)

IF(hour=1, (eqMaintenance.intervalof -(equipment.hours -eqMaintenance.hours)), (eqMaintenance.intervalof -(equipment.hours -eqMaintenance.miles)) AS DIFFERENCE

ORDER BY DIFFERENCE
Parameters:

condition: The condition to evaluate.
value_if_true: The value to return if the condition is true.
value_if_false: The value to return if the condition is false.

Example using IF() in a SELECT statement:
sql

SELECT product_id, price, IF(price > 100, 'Expensive', 'Affordable') AS category FROM products;

This query uses the IF() function to categorize products as 'Expensive' if the price is greater than 100, and 'Affordable' otherwise.
Using IF() with PHP:
You can incorporate the MySQL IF() function into your PHP code when constructing SQL queries. For example, to display a message based on the result of a database query, you can use PHP's if statements to handle different scenarios:
Mysql



1
06/06/2025
Mysql Date ADDDATE - Mysql
add date mysql
Mysql



3
02/15/2024
Mysql Date Select The MAX Date Of Each ID
max date unique group
Php
Mysql



2
09/09/2023
Mysql Query Generate The CREATE TABLE Statements
table create exec(
Table Dump
CREATE TABLE `cash` (
`cashid` mediumint(9) NOT NULL AUTO_INCREMENT,
`amount_total` smallint(6) NOT NULL,
`amount_split` smallint(6) NOT NULL,
`caleb` smallint(6) NOT NULL,
`jarrod` smallint(6) NOT NULL,
`received_on` datetime NOT NULL,
`farm` tinyint(4) NOT NULL,
`cutting` tinyint(4) NOT NULL,
`chk_cash` tinyint(4) NOT NULL,
`bale_count` smallint(6) NOT NULL,
`comment` varchar(50) NOT NULL,
`ave_price` decimal(8,2) NOT NULL,
PRIMARY KEY (`cashid`),
KEY `received_on` (`received_on`)
) ENGINE=MyISAM AUTO_INCREMENT=1683 DEFAULT CHARSET=latin1

CREATE TABLE `lastbackup` (
`backupid` mediumint(9) NOT NULL AUTO_INCREMENT,
`to` tinyint(4) NOT NULL,
`type` tinyint(4) NOT NULL,
`method` tinyint(4) NOT NULL,
`device` varchar(30) NOT NULL,
`table_name` varchar(30) NOT NULL,
` database_name` varchar(30) NOT NULL,
`destination` varchar(50) NOT NULL,
`received_on` datetime NOT NULL,
PRIMARY KEY (`backupid`),
KEY `received_on` (`received_on`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1




Programmatically with PHP
You can write a PHP script to connect to your MySQL database and execute queries to generate the CREATE TABLE statements. This is useful for building custom backup tools.
The following approach involves fetching table metadata and reconstructing the SQL, or leveraging PHP's ability to execute shell commands like mysqldump for simplicity:

Executing mysqldump from PHP: This method executes the command-line utility within your PHP script, which is often the most reliable way to get a perfect SQL structure dump.

php

=?php
$db_user = "your_username";
$db_pass = "your_password";
$db_name = "your_database";
$table_name = "your_table";
$output_file = "structure_export.sql";

// Command to export only the structure (--no-data)
$command = "mysqldump -u" . $db_user . " -p" . $db_pass . " " . $db_name . " " . $table_name . " --no-data > " . $output_file;

// Execute the command
exec($command, $output, $return_var);

if ($return_var === 0) {
echo "Table structure exported successfully to " . $output_file;
} else {
echo "Error exporting table structure.";
}
?=


=?php
ALL TABLES
function backup_mysql_database($host, $user, $pass, $dbname, $filename) {
// Ensure the output file has a .sql extension for clarity
if (substr($filename, -4) !== '.sql') {
$filename .= '.sql';
}

// Command to execute mysqldump:
// --opt is enabled by default and is recommended for speed and size
// --single-transaction allows a consistent backup without locking tables for InnoDB tables
$command = sprintf(
'mysqldump -h%s -u%s -p%s --opt --single-transaction %s > %s',
escapeshellarg($host),
escapeshellarg($user),
escapeshellarg($pass),
escapeshellarg($dbname),
escapeshellarg($filename)
);

$output = [];
$result_code = 0;

// Execute the command
exec($command, $output, $result_code);

if ($result_code === 0) {
return "Database dump successful. File saved as: $filename";
} else {
return "Error creating database dump. Command output: " . implode("n", $output);
}
}

// Configuration variables
$DBHOST = 'localhost';
$DBUSER = 'your_username';
$DBPASS = 'your_password';
$DBNAME = 'your_database_name';
$BACKUP_FILE = 'backup_' . date('Y-m-d_H-i-s') . '.sql';

// Run the backup function
$message = backup_mysql_database($DBHOST, $DBUSER, $DBPASS, $DBNAME, $BACKUP_FILE);

echo $message;
?=



=?php
$command = "ls -l"; // Command to list files and directories (on Unix-like systems)
$output_lines = [];
$return_status;

// Execute the command, capture output lines into $output_lines,
// and capture the exit code into $return_status
exec($command, $output_lines, $return_status);

echo "Command Executed:";
echo "$command";

echo "Output Lines:";

print_r($output_lines);
echo "Return Status:";
echo "$return_status"; // 0 usually means success
?=
Mysql



1
12/19/2025
Mysql Query Concat
concat mysql query
UPDATE parts SET pdf=CONCAT(partid,'.pdf'), part_image=CONCAT(partid,'.jpg') WHERE pdf=""

This example numbers the picture names to match the id of the record.

APENDING data before and after a field.
UPDATE `iwspackage` SET iwspackageimg=CONCAT('package',packageid,'.jpg');

UPDATE ads SET img1=CONCAT(adid,'a.jpg'), img2=CONCAT(adid,'b.jpg') , img3=CONCAT(adid,'c.jpg') , img4=CONCAT(adid,'d.jpg'), pdf=CONCAT(adid,'.pdf') WHERE adid>7;
Mysql



1933
09/09/2023
Mysql Query Group By
group by left join
SELECT category,categories.categoryid, COUNT(ads.categoryid) AS junk FROM categories LEFT JOIN ads ON categories.categoryid=ads.categoryid GROUP BY category ORDER BY category


SELECT products.productname, soldout, restock, count( orderedproducts.productid )
FROM categories, products, orderedproducts, orders
WHERE filled = 'Y'
AND orders.orderid = orderedproducts.orderid
AND orderedproducts.productid = products.productid
AND categories.catid = products.catid
AND orders.date>='2010-04-01' AND orders.date<='2010-04-30'
GROUP BY productname


SELECT * FROM `orderedproducts INNER JOIN orders ON orders.orderid=orderedproducts.orderid WHERE orders.date>='2010-04-01' AND orders.date<='2010-04-30'
Mysql



1331
09/09/2023
Mysql Query Finding Orphans Using Left Join
orphan parent left join null
Select * from table1groups left join table1 on table1groups.musgraveid=table1.musgraveid Where table1.musgraveid IS NULL LIMIT 0, 30

The results list only the records that do not have a parent
Mysql



1477
09/09/2023
Mysql Query Alter Tables
add field delete alter table rename update table auto increment engine collation
Mysql



1770
09/09/2023
Mysql Query Using INFORMATION_SCHEMA.COLUMNS To Retrieve Varchar Sizes
field size field length
Field Size Counter
php example stored field in an array
$r=new mysqli_swd();
$sql = "SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$database' AND TABLE_NAME = 'purchases' AND (DATA_TYPE = 'varchar' OR DATA_TYPE = 'text')";
$r->dbsql($sql);$result=$r->data;$num=$r->num;
if ($num > 0) {
while($row = $result->fetch_assoc()) {
$res[$row["COLUMN_NAME"]]= $row["CHARACTER_MAXIMUM_LENGTH"];
}
}
Mysql



0
06/05/2025
Mysql Query Different Types Of Queries
sum
Create Queries

SUM

SELECT SUM(amount) AS total_amount FROM orders;
Mysql



0
12/18/2025

Software Web Design