Data Definition Language (DDL) in SQL

The Data Definition Language (DDL) part of SQL permits database tables to be created or deleted. We can also define indexes (keys), specify links between tables, and impose constraints between database tables. The most important DDL statements in SQL are: • CREATE TABLE – creates a new database table • ALTER TABLE – alters (changes) … Read more

Characteristics of SQL Commands

Here you can see that SQL commands follow a number of basic rules: • SQL keywords are not normally case sensitive, though this in this tutorial all commands (SELECT, UPDATE etc) are upper-cased. • Variable and parameter names are displayed here as lower-case. • New-line characters are ignored in SQL, so a command may be … Read more

What is SQL?

Structured Query Language, commonly abbreviated to SQL and pronounced as “sequel”, is not a conventional computer programming language in the normal sense of the phrase. It allows users to access data in relational database management systems. SQL is about data and results, each SQL statement returns a result, whether that result be a query, an … Read more

PHP MySQL connector

php-mysql

PHP MySQL connector Example:  <html> <head> <title>Connecting MySQL Server</title> </head> <body> <?php $dbhost = ‘localhost:3306’; $dbuser = ‘guest’; $dbpass = ‘guest123’; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die(‘Could not connect: ‘ . mysql_error()); } echo ‘Connected successfully’; mysql_close($conn); ?> </body> </html> PHP 5 and later can work with a MySQL database using: … Read more

LOCATE() – MySQL Function

MySQL Function

LOCATE() – MySQL Function The LOCATE() function returns the position of the first occurrence of a substring in a string. If the substring is not found within the original string, this function returns 0. This function performs a case-insensitive search. LOCATE(substring, string, start) Parameter Description substring Required. The substring to search for in string string … Read more

time_to_sec MySQL function

MySQL Function

time_to_sec MySQL function The TIME_TO_SEC() function converts a time value into seconds. SELECT TIME_TO_SEC(“19:30:10”); Output: 70210 SELECT TIME_TO_SEC(“-03:30:00”); Output: -12600 PHP MySQL Program example of time_to_sec <!doctype html> <html lang=”en”> <head> <meta charset=”utf-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <title>example-time_to_sec-function – php mysql examples | w3resource</title> <meta name=”description” content=”PHP MySQL PDO Example”> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css”> </head> <body> … Read more

CONCAT() Function – MySQL

MySQL Function

CONCAT() Function – MySQL MySQL has the CONCAT() function, which allows you to concatenate two or more strings. The function actually allows for one or more arguments, but its main use is to concatenate two or more strings. CONCAT (string1, string2,…) Arguments string1 First string to be joined. string2 Second string to be joined. Up … Read more

TIMEDIFF – MySQL Function

MySQL Function

TIMEDIFF – MySQL Function This returns the difference between two datetime expressions: For example: SELECT TIMEDIFF(“2020-05-10 13:10:11”, “2020-05-05 13:10:10”); Output: 120:00:01 Let’s Understand the few things about timediff function The TIMEDIFF() function returns the difference between two time/datetime expressions. time1 and time2 should be in the same format, and the calculation is time1 – time2. … Read more