Skip to main content

Posts

Showing posts from November, 2021

SQL ORDER BY

SQL order by In this tutorial how to use the SQL order by clause with syntax and examples. SQL ORDER BY clause is used to sort the data or record using ASC | DESC. SQL ORDER BY sorts the records in ASC (ascending order) by default. syntax 1: SELECT column 1,column 2, .... column N FROM table_name ORDER BY column ...[ASC|DESC]; syntax 2: SELECT column 1,column 2, .... column N FROM table_name ORDER BY column ASC,column DESC; Here, we are created one table and named student_marks, and used order by to sort with marks and display it in the table.  create table student_marks ( s_id int primary key, s_name varchar(20) not null, maths int , english int, physics int , chemistry int, Tamil int, social int ); Insert the records in the table using the  INSERT INTO keyword. INSERT INTO: insert into student_marks values(101, 'Jack',25,52,35,85,45,55); insert into student_marks values(102, 'Rithvik',55,62,65...

SQL AND, OR and NOT Operators

In this tutorial, we are going to learn SQL AND, OR, NOT OPERATOR. with examples using SQL server. The where clauses are combined with AND, OR, NOT operators. where clause and with AND Operator have required two conditions are true. where clause and with OR operator have required one of two conditions is true. where clause with not-operator negates the conditions and displays others. AND Syntax: SELECT column1, column2, ... column N FROM table_name WHERE condition1 AND condition2 ... ; OR Syntax: SELECT column1, column2, ... column N FROM table_name WHERE condition1 OR condition2; NOT Syntax: SELECT column1, column2, ... column N FROM table_name WHERE NOT condition; Now, we are going to create a table and name as a student in the SQL server create table student ( s_id int primary key, s_name varchar(20) not null, score int not null, status varchar(20) not null, city varchar(...

SQL Between

SQL BETWEEN  In this tutorial, you will learn how to use SQL Between operator in SQL Server The SQL BETWEEN operator is a logical operator that allows to fetched the certain range in the specified table. SELECT column_name FROM table_name WHERE column_name BETWEEN Start_value AND End_value; First, use the select keyword and specify the column name or use * get full table data.  second, mention the table name and place the start_value and End_value between the Between keyword have the same data type. Here, the condition that is using Between operator that uses the operators >=, <=, AND, IN.  AND used Between operator, not Between operator. we already create the student table from the sample database   student table id (primary key), student_name, class, age, phone_no, BETWEEN SELECT student_name, class, age FROM student WHERE age BETWEEN 15 and 16; ...

SQL Insert

SQL Insert into statement In this tutorial, we explain how to SQL insert into a statement insert the new record in the SQL database table. Syntax: SQL Insert into table syntax: INSERT INTO table_name(column 1,column 2,.....column N) VALUES (values 1,values 2,....); In the above syntax, you will see the both specified column and values to be inserted query. In case you will add values for all of the tables, you will be adding a table in the SQL query. you don't need to specify the column names. Here, Below how to use syntax to insert the values to follow:   INSERT INTO table_name VALUES (values 1,values 2,....); create table student(id int not null primary key,student_name varchar(25) not null, class int not null,age int not null,phone_no varchar(20) not null); INSERT into student(id,student_name,class,age,phone_no) values(101,'varun', 6 , 15, 9874563211); INSERT into student(id,student_name,class,age...

SQL where

In this tutorial, we explain how to use them where clause in SQL . The SQL where clause is used to filter the results and fetch the particular data or record and the where clause conditions apply also in a SELECT, INSERT, UPDATE OR DELETE statement. Syntax: Where [conditions]; SELECT column1, column 2,column n ,... FROM table_name WHERE condition; The SQL where clause is difficult to explain with syntax, so let's start the examples. Here we are creating a database and creating a table in SQL . Just I create a table and named it a student table. create table student(id int not null primary key,student_name varchar(25) not null, class int not null,age int not null,phone_no varchar(20) not null); some data should be inserted using the INSERT statement. INSERT into student(id,student_name,class,age,phone_no) values(101,'varun', 6 , 15, 9874563211); INSERT into student(id,student_name,class,age,phone_no) values(101,'varun', ...

SQL create table

SQL create table The create table statement is used to create a table in the SQL database. and it involves naming the table also. Defining tables and columns within the create table statement. Syntax: CREATE TABLE table_name( column 1 datatype, column 2 datatype, column 3 datatype, N column datatype, Primary key(column) ); When we are using the keyword CREATE TABLE to the database to tell want to create a new table. The table must be the unique and non-repeated name and just we define to the database. and then brackets inside define the list of columns. In this case, you can list the column in the table. Let take an example we are creating an employee table with Id as the primary key and NOT NULL are the constraint showing to creating records in the table. CREATE TABLE Employee( Id int not null, Name varchar(20) not null, Age int not null, Dept varchar(25) not null, Salary varchar(20) not null, ...

PHP JSON Array Merge

In this tutorial, we are going to merge a JSON array using PHP , we have three student data to be merged together. The JSON objects will be decoded into an associative array and after the encoded array merge. PHP can be merging one or more JSON arrays in various ways. for example using of PHP array_merge() function. Here, PHP JSON ARRAY Merge has two methods are works in one example:  syntax:array_merge(array1, array2, array3, ...)  JSON ARRAY IN PHP <?php $student1 = '{ "id": "101", "student_name": "chandra", "class": "6", "status": "present" }'; $student2 = '{ "id": "102", "student_name": "Anbu", "class": "6", "status": "absent" }'; $student3 ='{ "id":"103", "student_name":"priya", "class":"6...

PHP JSON Array tutorial with Example

PHP and JSON PHP helps to handle JSON has some built-in functions.  PHP allow us to JSON encode and decode help of this two functions: Json_encode() Json_decode() PHP Array to JSON - Json_encode Json_encode()   the function is to return the encoded value to JSON format. Syntax: Json_encode(mixed $value,int $flags,int $depth= 512) value − The value being encoded UTF-8 data. flags − JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT . <?php //associative array into a JSON object $age = array("chandra"=>28, "roshan"=>13, "priya"=>24); echo json_encode($age); ?> Output: {"chandra":28,"roshan":13,"priya":24} <?php class student { public $firstname = ""; public $class = ""; public $age = ""; } $s = new student(); $s->f...

PHP CRUD MySQLi operation tutorial for beginners

In this tutorial how to create a CRUD operation using PHP and MYSQLi And crud operations stands for Create, Read, Update and Delete the records in the database. Create an empty files in this tutorials:  index.php dbconfig.php  add_student.php  view_student.php  Edit_student.php  Delete_student.php PHP CRUD MSQLi Operation:  In the first step, we are creating a database in PHPMyAdmin and named as ' studentdb ' and creating a table using SQL query tabs, and copy and pasting the below query. Second, create a database connection named ' dbconfig.php ' insert a record using PHP coding. And create a form and do post method for data insertion and create table using HTML and design using bootstrap and make a beautiful design. CREATE TABLE `student`( `id` INT(11) NOT NULL AUTO_INCREMENT,`Id` VARCHAR(255), `Name` VARCHAR(255),`Age` numeric(60) DEFAULT NULL, `Address` TEXT,`Mobileno` numeric(60) DEFAULT NULL, `Sex` VARCHAR(255),PRIMARY KEY (`id...