Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjayakumars committed Apr 12, 2021
1 parent cd1d330 commit 48aeaea
Show file tree
Hide file tree
Showing 64 changed files with 912 additions and 742 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Code/.DS_Store
Binary file not shown.
23 changes: 0 additions & 23 deletions Code/PHP MySQL - ALTER TABLE -1.php

This file was deleted.

23 changes: 0 additions & 23 deletions Code/PHP MySQL - ALTER TABLE -2.php

This file was deleted.

23 changes: 0 additions & 23 deletions Code/PHP MySQL - ALTER TABLE -3.php

This file was deleted.

46 changes: 46 additions & 0 deletions Code/PHP MySQL - AND - OR and NOT Operators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
// Create connection
$con = mysqli_connect(localhost, 'root', 'root', 'myDB');

// Check connection
if (!$con) {
die('Connection failed: ' . mysqli_connect_error());
}

//AND OPERATOR --------------------------------------
echo '<h4>mySQL - AND operator</h4>';
$result = mysqli_query($con, "SELECT * from student WHERE course = 'mba' AND location='vellore'");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]);
printf('<br>');
}

print '<hr>';

//OR OPERATOR --------------------------------------

echo '<h4>mySQL - OR operator</h4>';
$result = mysqli_query($con, "SELECT * from student WHERE course = 'PHD' OR location='OHIO' OR age='30'");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]);
printf('<br>');
}

print '<hr>';

//NOT OPERATOR --------------------------------------
echo '<h4>mySQL - NOT operator</h4>';
$result = mysqli_query($con, "SELECT * from student WHERE NOT course = 'mba' AND location='vellore'");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]);
printf('<br>');
}
print '<hr>';
//TWO NOT OPERATOR --------------------------------------
echo '<h4>mySQL - NOT operator - TWO TIMES</h4>';
$result = mysqli_query($con, "SELECT * from student WHERE NOT course = 'mba' AND NOT location='vellore'");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]);
printf('<br>');
}
mysqli_close($conn);
61 changes: 61 additions & 0 deletions Code/PHP MySQL - BETWEEN FUNCTION.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
// Create connection
$con = mysqli_connect(localhost, 'root', 'root', 'myDB');

// Check connection
if (!$con) {
die('Connection failed: ' . mysqli_connect_error());
}

//BETWEEN Function --------------------------------------
echo '<h4>mySQL - BETWEEN Function </h4>';
$result = mysqli_query($con, 'SELECT RegNo, AGE from student WHERE AGE BETWEEN 20 AND 30');
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

print '<hr>';

//NOT BETWEEN Function --------------------------------------
echo '<h4>mySQL - NOT BETWEEN Function </h4>';
$result = mysqli_query($con, 'SELECT RegNo, AGE from student WHERE AGE NOT BETWEEN 20 AND 30');
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

print '<hr>';

// BETWEEN - TEXT VALUE Function --------------------------------------
echo '<h4>mySQL - BETWEEN - TEXT VALUE Function </h4>';
$result = mysqli_query($con, "SELECT RegNo, FIRSTNAME from student WHERE FIRSTNAME BETWEEN 'A' AND 'D'");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

print '<hr>';

//NOT BETWEEN - TEXT VALUE Function --------------------------------------
echo '<h4>mySQL - NOT BETWEEN Function </h4>';
$result = mysqli_query($con, "SELECT RegNo, FIRSTNAME from student WHERE FIRSTNAME NOT BETWEEN 'A' AND 'P'");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

print '<hr>';

//BETWEEN - DATE Function --------------------------------------
echo '<h4>mySQL - DATE BETWEEN Function </h4>';
$result = mysqli_query($con, "SELECT RegNo, FIRSTNAME from student WHERE FIRSTNAME BETWEEN '2020-01-01' AND '2021-03-31' ");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

print '<hr>';

mysqli_close($con);
?>
43 changes: 43 additions & 0 deletions Code/PHP MySQL - BETWEEN WITH IN FUNCTION.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
// Create connection
$con = mysqli_connect(localhost, 'root', 'root', 'myDB');

// Check connection
if (!$con) {
die('Connection failed: ' . mysqli_connect_error());
}


//BETWEEN with IN Function --------------------------------------
echo '<h4>mySQL - BETWEEN with IN Function </h4>';
$result = mysqli_query($con, "SELECT RegNo, AGE from student WHERE AGE BETWEEN 20 AND 30 AND COURSE IN ('MBA')");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

print '<hr>';

//BETWEEN with NOT IN Function --------------------------------------
echo '<h4>mySQL - BETWEEN with NOT IN Function </h4>';
$result = mysqli_query($con, "SELECT RegNo, AGE from student WHERE AGE BETWEEN 20 AND 30 AND COURSE NOT IN ('MBA')");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

print '<hr>';


//BETWEEN with NOT IN Function - OR OPERATOR --------------------------------------
echo '<h4>mySQL - BETWEEN with NOT IN Function - OR OPERATOR </h4>';

$result = mysqli_query($con, "SELECT COURSE, AGE from student WHERE AGE BETWEEN 20 AND 30 OR COURSE NOT IN ('MBA')");

while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf('%s ---- %s', $row[0], $row[1]);
echo '<br>';
}

mysqli_close($con);
?>
60 changes: 0 additions & 60 deletions Code/PHP MySQL - BETWEEN.php

This file was deleted.

8 changes: 8 additions & 0 deletions Code/PHP MySQL - CREATE DATABASE CONNECTION.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
$con = mysqli_connect("localhost", "root", "root");
if (!$con) {
die("Connection failed:" . mysqli_connect_error());
}
echo "Connected successfully";
mysqli_close($con);
?>
20 changes: 6 additions & 14 deletions Code/PHP MySQL - CREATE DATABASE.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?php
$servername = "localhost";
$username = "jay";
$password = "";

// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
<?php
$con = mysqli_connect("localhost", "root", "root");
if (!$con) {
die('Could not connect: ' . mysqli_connect_error());
}

// Create database
$sql = "CREATE DATABASE myDB";
if (mysqli_query($conn, $sql)) {
if (mysqli_query($con, $sql)) {
echo "Database created successfully";
} else {
echo "Error creating database: " . mysqli_error($conn);
echo "Error creating database: " . mysqli_errno($con);
}

mysqli_close($conn);
Expand Down
29 changes: 29 additions & 0 deletions Code/PHP MySQL - CREATE TABLE - 1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
//Connection
$con = mysqli_connect("localhost", "root", "root");
if (!$con) {
die('Could not connect: ' . mysqli_connect_error());
} else {
echo "Connection Connected <br>";
}

//Database Selection

//mysqli_select_db($con, "myDBdd");
if (mysqli_select_db($con, "myDB")) {
echo "Database Selected Successfully <br>";
} else {
echo "Error in Selecting the Database <br>", mysqli_errno($con);
}

//Table Creation

$sql = "create table student (FirstName varchar(25), LastName varchar(25), Age varchar(3))";

if (!mysqli_query($con, $sql)) {
die('Error: ' . mysqli_errno($con));
}
echo "Table Created Successfully";

mysqli_close($con);
?>
35 changes: 35 additions & 0 deletions Code/PHP MySQL - CREATE TABLE - 2 - PRIMARY KEY AND NOT NULL.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
//Connection
$con = mysqli_connect('localhost', 'root', 'root');
if (!$con) {
die('Could not connect: ' . mysqli_connect_error());
} else {
echo 'Connection Connected <br>';
}

//Database Selection

//mysqli_select_db( $con, 'myDBdd' );
if (mysqli_select_db($con, 'myDB')) {
echo 'Database Selected Successfully <br>';
} else {
echo 'Error in Selecting the Database <br>', mysqli_errno($con);
}

//Table Creation

$sql = "create table student (
RegNo varchar(25) NOT NULL,
FirstName varchar(25),
LastName varchar(25),
Age varchar(3),
PRIMARY KEY (RegNo)
)";

if (!mysqli_query($con, $sql)) {
die('Error: ' . mysqli_errno($con));
}
echo 'Table Created Successfully';

mysqli_close($con);
?>
Loading

0 comments on commit 48aeaea

Please sign in to comment.