Font Size
Free Script installer FORUMS Ad management Portals and Cms Blogs Welcome Hepsia cPanel hosting
Free Script installer
You're about to get acquainted with a brand new mechanism of installing and managing PHP scripts. Our Elefante Installer allows you to install and manage blogs, forums, image galleries, content management systems, e-shops and many more, without any knowledge of basic programming languages such as HTML, PHP, etc. The Elefante Installer is a FREE PHP web application services installer which makes it easy for you to automatically install over 40 popular PHP script packages straight from your personal Web Hosting Control Panel or have the script insalled when you sign up ready for use.
Read the Full Story
FORUMS
An Internet forum is a discussion area on a website. Website members can post discussions and read and respond to posts by other forum members. An Internet forum can be focused on nearly any subject and a sense of an online community, or virtual community, tends to develop among forum members.
Read the Full Story
Ad management

Ad Management Scripts/Software

Pop-ups and other kinds of advertisements are a constant irritation for many Internet users. But, like all things media (such as television and radio), the web can't continue to exist without them. Whether webmasters like it or not, advertising helps pay their bills to keep their sites running. Therefore, it's always a good idea to know how to make them work for you. One way you can do this is to use ad management scripts or software. The sheer number available, online or otherwise, guarantees that you'll be able to find one that will fit your needs and budget.
Read the Full Story
Portals and Cms
A portal Web site is a Web site that aims to be your "portal," or entranceway,  to most anything you can do on the Web. For example, Yahoo is considered a  portal because it offers a search engine that helps you find other Web sites, as  well as topics categories such as finance,  travel, health, etc. that help you find information on the Web about those  topics. In the 1998-2001 phase of the Internet, many Web sites aspired to be  portals, because they believed it would mean users would use them as their  "start page" and visit frequently, even if they eventually left to visit other  Web sites. However, these days, most Web sites do not want to be mere start  pages; they want to keep you on their Web site for as long as possible, and not  take you to other Web sites.
Read the Full Story
Blogs

What's a blog?

A blog is a personal diary. A daily pulpit. A collaborative space. A political soapbox. A breaking-news outlet. A collection of links. Your own private thoughts. Memos to the world. Your blog is whatever you want it to be. There are millions of them, in all shapes and sizes, and there are no real rules. In simple terms, a blog is a website, where you write stuff on an ongoing basis. New stuff shows up at the top, so your visitors can read what's new. Then they comment on it or link to it or email you. Or not
Read the Full Story
Welcome
  • Upto unlimited GB Disc Space
  • Upto Unlimited Data Transfer
  • FTP, Stats
  • Upto unlimited Email Accounts
  • Free sub Domain Name
  • Free Site Builder
  • Unlimited Domain Hosting
 
Read the Full Story
Hepsia cPanel hosting

Hepsia Control Panel Top Features

You can now register, transfer or manage multiple domain names & websites from just one place. This is something cPanel has big problems with. Actually there is no Domain Manager at all in cPanel. With Hepsia you can set up and manage multiple fully independent websites from a single account. No need to have separate control panels (i.e. logins) for your domains, support tickets and billing.
Read the Full Story

 

24 Best PHP Open Source CMS

24 Best PHP Open Source CMS

Open Source CMS

If you want to start your own website and you don’t know what CMS to use, then read this article in which I’ve done a roundup of 24 open source Php content management systems,

Readers who don’t have strong PHP knowledge can easily create their website using free and open source CMS.

1. WordPress

 

WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time.

The core software is built by hundreds of community volunteers, and when you’re ready for more there are thousands of plugins and themes available to transform your site into almost anything you can imagine. Over 60 million people have chosen WordPress to power the place on the web they call “home” — we’d love you to join the family.

 

 

2. Drupal

 

 

Use Drupal to build everything from personal blogs to enterprise applications.

Read More...

Server ICONS

Server ICONS

This icon pack includes 12 server based icons in transparent PNG, ICO (Windows) and ICNS (Mac) format. Each icon is supplied in 512px, 256px, 128px, 64px and 32px variations.

1) Server Processor Micro Chip 2) RAM 3) Bandwidth 4) Instant Setup 5) Hard Drive Stack 6) RAID Tower 7) Remote Server Reboot Button 8) 99.99% SLA Contract 9) Server Backup 10) Root Access Console 11) Server Control Panel 12) IP Addresses

 

 

Download File – Internet Icons V2

« Previous Pricing Grid   Next » 24 Best PHP Open Source CMS

Posts Related to Server ICONS

  • How to stop a directory listing of your folders

    How to Prevent a Directory Listing of Your Website with .htaccess If you create a new directory (or folder) on your website, and do not ...

  • Dedicated server Service Level Guarantees

    Dedicated Server Terms Acceptable Use Policy for Dedicated Servers Service Level Guarantees for Dedicated Servers   Dotnet Web Hosting Service Level Guarantees SERVICE GUARANTEES 99.9% ...

  • MySQL tutorial MySQL database introduction

    MySQL database introduction   The MySQL database package consists of the following: The MySQL server: This is the heart of MySQL. You can consider it ...

  • MySQL tutorial Installing MySQL on Windows

    Installing MySQL on Windows   Once you have successfully downloaded the Windows version, installing it is a breeze... trust me! (The installation steps below have ...

  • Change file permissions

     Changing file/folder permissions All files on UNIX (including Linux and other UNIX variants) machines have access permissions.

Read More...

Pricing Grid

Pricing Grid

“ Pricing Grid” download here

A) HTML Structure - Horizontal Layout Below is the structure of a pricing grid container <div class="apg-hori apg-hori-2"> OPTIONS GO HERE </div> Specify the number of options you want by using the following classes apg-hori-2, apg-hori-3, apg-hori-4, apg-hori-5To add the options, use the html structure provided below and place each option container in the order you want them displayed. Below is the structure of a pricing grid option box <div class="apg-option "> <div class="apg-header"> <h1>Standard</h1> <span class="apg-price">$35<span class="label">/Mo</span></span> </div> <ul> <li><strong>5</strong> Users</li> <li><strong>5GB</strong> Space</li> <li><strong>20</strong> Email Accounts</li> <li><strong>5GB</strong> Bandwidth</li> <li><strong>5</strong> Domains</li> </ul> <a href="javascript:;" class="button">Order Now</a> </div> How to edit the features list To edit the features list, modify the items in the unordered list. To add an icon to a list item, first you must define your icon class in the css file (example below). Then add this class to the LI tag of the item you want to add the icon to. Note: Only five icons from the FamFamFam icon package were used in this example. Many more icons can be downloaded at their website http://www.famfamfam.com/lab/icons/silk/ .user strong { background: url(./images/silk/user.png) no-repeat 0 0; padding-left: 24px; } How to create a featured option To create a featured option, add the class apg-featuredto an apg-option container. How to change the header color(s) To change the color of the pricing grid header, open the build-hori-header.png file located in the build directory.

Read More...

PHP script to find malicious code on a hacked server

PHP script to find malicious code on a hacked server

PHP script to find malicious code on a hacked server

When hackers get into a server, they often modify files to inject malicious code, install PHP backdoor scripts, or modify .htaccess to redirect requests to another site.

There are several methods of finding the changes they made. The PHP script below is one method. It searches for suspiciouscode or other text that is often found in modified files and in backdoor scripts, for suspicious filenames, and for traces of the WordPress “pharma” hack that makes an ordinary WordPress site look like it’s suddenly been turned into an online pharmacy.

The method this script uses is “signature-based”; it searches for specific snippets of suspect code.  

I’ve expanded on it, adding checks for potential error conditions, adding extensive use of regular expressions, adding a routine to sanitize text output to the report page, and organizing, formatting, and commenting it to make it as easy as possible to understand and further expand or customize for a particular use.

Please read through the script with some care before using it. There is at least one line of code that you must customize, and other sections that advanced users might want to customize. In addition, the comments contain notes about things such as when a particular suspicious snippet should be considered especially suspicious, or when it is likely to be a false positive.

Read More...

Internet browsers

Internet browsers

Why should you use the latest browser version?

 

Though its generally suggested using the newest browser version, this might not be a good idea especially when you’re working on an old computer (anything machine that’s more than 3 years old). Please note that upgraded software would typically not be able to run properly – it would either be very slow or cause a whole lot of other problems with other installed programs on your computer.

For instance, when I installed the latest version of Internet Explore (8, at the time of writing) on a Windows XP laptop, things moved at a snails pace. I was better off with the older version, right?

But out-dated browser versions present their own set of problems – security being the most important. So if you are using an old computer I recommend switching to another program – one which is light-weight and can run fast on your machine. Take a look at some alternative’s in the big web browsers list… you don’t need to use one of the popular web browsers.

For majority of users, here are some reasons to upgrade to the latest browser version:

  • Security: Typically, the newer version of the browser will have patches for security holes.
  • Faster rendering engines: Though downloading speed is dependent on the internet connection, the latest browser version will render web sites faster than its predecessor.

Read More...

MySQL tutorial What Next?

MySQL tutorial What Next?

What Next?

The tutorial has covered almost everything a web developer needs to know in order to get started and develop online databases. For those of you who are hungry for more, here are two important resources.

MySQL Reference Manual

Go to the MySQL web site and download the manual. The manual is offered in various formats. I have a .pdf version. Click here to be taken to the resources page directly.

« Previous MySQL tutorial Column Types part 2   Next » Internet browsers

Posts Related to MySQL tutorial What Next?

  • MySQL tutorial Downloading MySQL

    Downloading MySQL MySQL is available for Windows, Linux and other Unix variants. The Windows version is a shareware, which must registered after evaluation. I learnt ...

  • MySQL tutorial SQL Tutorial

    SQL Tutorial   What is SQL? The Structured Query Language is used in manipulating data stored in Relational Database Management Systems (RDBMS). SQL provides commands ...

  • Hotlink Protection

    Hotlink Protection Hotlink Protection prevents other web sites from directly linking to certain files (typically images) that are on your web site. This tutorial will ...

  • MySQL tutorial Creating a database

    Creating a database In this section of the MySQL primer we will learn how to create a database. The commands for creating a database in ...

  • MySQL tutorial Installing MySQL on Windows

    Installing MySQL on Windows   Once you have successfully downloaded the Windows version, installing it is a breeze... trust me! (The installation steps below have ...

Read More...

MySQL tutorial Column Types part 2

MySQL tutorial Column Types part 2

Column Types part 2

MySQL Text data type

Text can be fixed length (char) or variable length strings. Also, text comparisions can be case sensitive or insensitive depending on the type you choose.

  • CHAR(x): where x can range from 1 to 255.
  • VARCHAR(x): x ranges from 1 – 255
  • TINYTEXT: small text, case insensitive
  • TEXT: slightly longer text, case insensitive
  • MEDIUMTEXT: medium size text, case insensitive
  • LONGTEXT: really long text, case insensitive
  • TINYBLOB: Blob means a Binary Large OBject. You should use blobs for case sensitive searches.
  • BLOB: slightly larger blob, case sensitive.
  • MEDIUMBLOB: medium sized blobs, case sensitive.
  • LONGBLOB: really huge blobs, case sensitive.
  • ENUM: Enumeration data type have fixed values and the column can take only one value from the given set. The values are placed in parenthesis following ENUM declaration. An example, is the marital status column we encountered in employee_per table. m_status ENUM("Y", "N")

    Thus, m_status column will take only Y or N as values. If you specify any other value with the INSERT statement, MYSQL will not return an error, it just inserts a NULLvalue in the column.

  • SET: An extension of ENUM. Values are fixed and placed after the SET declaration; however, SET columns can take multiple values from the values provided. Consider a column with the SET data type as

    hobbies SET ("Reading", "Surfing", "Trekking", "Computing")

    You can have 0 or all the four values in the column.

    INSERT tablename (hobbies) values ("Surfing", "Computing");
« Previous MySQL database Column Types   Next » MySQL tutorial What Next?

Posts Related to MySQL tutorial Column Types part 2

  • MySQL tutorial Creating tables

    Creating tables In this section of the mysql training course we will explore the MySQL commands to create database tables and selecting the database.

Read More...

MySQL database Column Types

MySQL database Column Types

MySQL database Column Types

The three major types of column types used in MySQL are

  • Integer
  • Text
  • Date

Choosing a column data type is very important in order to achieve speed, effective storage and retrieval. Hence, I’ve dedicated two sessions to this topic. Now, I’ll be touching only the surface; for a thorough explanation refer the resources in What Next? session.

MySQL Numeric Column Types

In addition to int (Integer data type), MySQL also has provision for floating-point and double precision numbers. Each integer type can take also be UNSIGNED and/or AUTO_INCREMENT.

  • TINYINT: very small numbers; suitable for ages. Actually, we should have used this data type for employee ages and number of children. Can store numbers between 0 to 255 if UNSIGNED clause is applied, else the range is between -128 to 127.
  • SMALLINT: Suitable for numbers between 0 to 65535 (UNSIGNED) or -32768 to 32767.
  • MEDIUMINT: 0 to 16777215 with UNSIGNED clause or -8388608 to 8388607.
  • INT: UNSIGNED integers fall between 0 to 4294967295 or -2147683648 to 2147683647.
  • BIGINT: Huge numbers. (-9223372036854775808 to 9223372036854775807)
  • FLOAT: Floating point numbers (single precision)
  • DOUBLE: Floating point numbers (double precision)
  • DECIMAL:Floating point numbers represented as strings.

Date and time column types

  • DATE: YYYY-MM-DD (Four digit year followed by two digit month and date)
  • TIME: hh:mm:ss (Hours:Minutes:Seconds)
  • DATETIME: YYYY-MM-DD hh:mm:ss (Date and time separated by a space character)
  • TIMESTAMP: YYYYMMDDhhmmss
  • YEAR: YYYY (4 digit year)
« Previous MySQL tutorial Dropping tables   Next » MySQL tutorial Column Types part 2

Posts Related to MySQL database Column Types

  • MySQL Date column type part 1

    MySQL Date column type part 1 Till now we've dealt with text (varchar) and numbers (int) data types.

Read More...

MySQL tutorial Dropping tables

MySQL tutorial Dropping tables

Dropping tables

To remove all entries from the table we can issue the DELETE statement without any conditions.

DELETE from employee_data; Query OK, 0 rows affected (0.00 sec)

However, this does not delete the table. The table still remains, which you can check with SHOW TABLES;

mysql> SHOW TABLES; +---------------------+ | Tables in employees | +---------------------+ | employee_data | +---------------------+ 1 rows in set (0.00 sec)

To delete the table, we issue a DROP table command.

DROP TABLE employee_data; Query OK, 0 rows affected (0.01 sec)

Now, we won’t get this table in SHOW TABLES; listing

« Previous MySQL tutorial Deleting entries from tables   Next » MySQL database Column Types

Posts Related to MySQL tutorial Dropping tables

  • MySQL tutorial Deleting entries from tables

    Deleting entries from tables The SQL delete statement requires the table name and optional conditions. DELETE from table_name [WHERE conditions]; NOTE: If you don't specify ...

  • MySQL tutorial MySQL tables

    MySQL tables Now that we've created our employee_data table, let's check its listing. Type SHOW TABLES; at the mysql prompt. This should present you with ...

  • MySQL tutorial Creating tables

    Creating tables In this section of the mysql training course we will explore the MySQL commands to create database tables and selecting the database. Databases ...

  • MySQL tutorial Inserting data in MySQL tables

    Inserting data in MySQL tables Inserting data into tables The INSERT SQL statement impregnates our table with data.

Read More...

MySQL tutorial Deleting entries from tables

MySQL tutorial Deleting entries from tables

Deleting entries from tables

The SQL delete statement requires the table name and optional conditions.

DELETE from table_name [WHERE conditions];

NOTE: If you don’t specify any conditions ALL THE DATA IN THE TABLE WILL BE DELETED!!!

One of the Multimedia specialists ‘Hasan Rajabi’ (employee id 10) leaves the company. We’ll delete his entry.

DELETE from employee_data WHERE emp_id = 10; Query OK, 1 row affected (0.00 sec) « Previous MySQL tutorial table joins   Next » MySQL tutorial Dropping tables

Posts Related to MySQL tutorial Deleting entries from tables

  • MySQL tutorial Dropping tables

    Dropping tables To remove all entries from the table we can issue the DELETE statement without any conditions. DELETE from employee_data; Query OK, 0 rows ...

  • MySQL tutorial SQL Tutorial

    SQL Tutorial   What is SQL? The Structured Query Language is used in manipulating data stored in Relational Database Management Systems (RDBMS). SQL provides commands ...

  • MySQL tutorial Updating records

    Updating records The SQL UPDATE command updates the data in tables. Its format is quite simple. UPDATE table_name SET column_name1 = value1, column_name2 = value2, ...

  • MySQL tutorial Querying MySQL tables

    Querying MySQL tables Our employee_data table now contains enough data for us to work with. Let us see how we can extract (query) it. Querying ...

  • MySQL tutorial Inserting data in MySQL tables

    Inserting data in MySQL tables Inserting data into tables The INSERT SQL statement impregnates our table with data.

Read More...

MySQL tutorial table joins

MySQL tutorial table joins

MySQL table joins

Till now, we’ve used SELECT to retrieve data from only one table. However, we can extract data from two or more tables using a single SELECT statement. The strength of RDBMS lies in allowing us to relate data from one table with data from another. This correlation can only be made if atleast one column in the two tables contain related data. In our example, the columns that contain related data are emp_id of employee_data and e_id of employee_per.

Let’s conduct a table join and extract the names (from employee_data) and spouse names (from employee_per) of married employee.

select CONCAT(f_name, " ", l_name) AS Name, s_name as 'Spouse Name' from employee_data, employee_per where m_status = 'Y' AND emp_id = e_id; +-----------------+-----------------+ | Name | Spouse Name | +-----------------+-----------------+ | Manish Sharma | Anamika Sharma | | John Hagan | Jane Donner | | Ganesh Pillai | Sandhya Pillai | | Anamika Sharma | Manish Sharma | | John MacFarland | Mary Shelly | | Alok Nanda | Manika Nanda | | Paul Simon | Muriel Lovelace | | Arthur Hoopla | Rina Brighton | | Kim Hunter | Matt Shikari | | Danny Gibson | Betty Cudly | | Mike Harper | Stella Stevens | | Monica Sehgal | Edgar Alan | | Peter Champion | Ruby Richer | +-----------------+-----------------+ 13 rows in set (0.00 sec)

The FROM clause takes the names of the two tables from which we plan to extract data.

Read More...

MySQL tutorial Null column type

MySQL tutorial Null column type

Null column type

The NULL column type is special in many ways. To insert a NULL value, just leave the column name from the INSERT statement. Columns have NULL as default unless specified by NOT NULL. You can have null values for integers as well as text or binary data. NULL cannot be compared using arithemetic operators. Comparisions for NULL take place with IS NULL or IS NOT NULL.

select e_id, children from employee_per where children IS NOT NULL; +------+----------+ | e_id | children | +------+----------+ | 2 | 3 | | 3 | 2 | | 7 | 3 | | 9 | 1 | | 11 | 4 | | 12 | 3 | | 13 | 2 | | 15 | 3 | | 16 | 2 | | 17 | 1 | | 21 | 2 | +------+----------+ 11 rows in set (0.00 sec)

The above lists ids and no.

Read More...

MySQL Date column type part 2

MySQL Date column type part 2

MySQL Date column type part 2

Using Date to sort data

select e_id, birth_date from employee_per ORDER BY birth_date; +------+------------+ | e_id | birth_date | +------+------------+ | 11 | 1957-11-04 | | 16 | 1964-03-06 | | 21 | 1964-06-13 | | 14 | 1965-04-28 | | 15 | 1966-06-23 | | 7 | 1966-08-20 | | 10 | 1967-07-06 | | 20 | 1968-01-25 | | 12 | 1968-02-15 | | 2 | 1968-04-02 | | 9 | 1968-05-19 | | 13 | 1968-09-03 | | 3 | 1968-09-22 | | 6 | 1969-12-31 | | 17 | 1970-04-18 | | 1 | 1972-03-16 | | 4 | 1972-08-09 | | 19 | 1973-01-20 | | 18 | 1973-10-09 | | 5 | 1974-10-13 | | 8 | 1975-01-12 | +------+------------+

Selecting data using Dates

Here is how we can select employees born in March.

select e_id, birth_date from employee_per where MONTH(birth_date) = 3; +------+------------+ | e_id | birth_date | +------+------------+ | 1 | 1972-03-16 | | 16 | 1964-03-06 | +------+------------+ 2 rows in set (0.00 sec)

Alternatively, we can use month names instead of numbers.

select e_id, birth_date from employee_per where MONTHNAME(birth_date) = 'January'; +------+------------+ | e_id | birth_date | +------+------------+ | 8 | 1975-01-12 | | 19 | 1973-01-20 | | 20 | 1968-01-25 | +------+------------+ 3 rows in set (0.00 sec)

Be careful when using month names as they are case sensitive.

Read More...

MySQL Date column type part 1

MySQL Date column type part 1

MySQL Date column type part 1

Till now we’ve dealt with text (varchar) and numbers (int) data types. To understand date type, we’ll create one more table. Download employee_per.dat file below and follow the instructions. The file contain the CREATE table command as well as the INSERT statements.

employee_per.dat

These instructions are a repeat of those in session 6 and 8.

Windows system 1). Move the file to c:\mysql\bin. 2). Issue the command at DOS prompt. dosprompt> mysql employees <employee_per.dat 3). Start mysql client program and check if the table has been created using SHOW TABLES; command.

Linux system 1). Move to the directory that contains the downloaded files. 2). At the prompt, type the command below: $prompt> mysql employees <employee_per.dat -u your_username -p 3).

Read More...

MySQL tutorial Updating records

MySQL tutorial Updating records

Updating records

The SQL UPDATE command updates the data in tables. Its format is quite simple.

UPDATE table_name SET column_name1 = value1, column_name2 = value2, column_name3 = value3 ... [WHERE conditions];

Obviously, like other SQL commands, you can type in in one line or multiple lines.

Let’s look at some examples. Bignet has been doing good business, the CEO increases his salary by $20000 and perks by $5000. His previous salary was $200000 and perks were $50000.

UPDATE employee_data SET salary=220000, perks=55000 WHERE title='CEO'; Query OK, 1 row affected (0.02 sec) Rows matched: 1 Changed: 1 Warnings: 0

You can test this out by listing the data in the table.

select salary, perks from employee_data WHERE title = 'CEO'; +--------+-------+ | salary | perks | +--------+-------+ | 220000 | 55000 | +--------+-------+ 1 row in set (0.00 sec)

Actually, you don’t need to know the previous salary explicitly. You can be cheeky and use arithmetic operators. Thus, the following statement would have done the same job without us knowing the original data beforehand.

UPDATE employee_data SET salary = salary + 20000, perks = perks + 5000 WHERE title='CEO'; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0

Another progressive (???) step Bignet takes is changing the titles of Web Designer to Web Developer.

mysql> update employee_data SET -> title = 'Web Developer' -> WHERE title = 'Web Designer'; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0

It’s important that you take a long hard look at the condition part in the statement before executing update, else you might update the wrong data.

Read More...

MySQL mathematical Functions

MySQL mathematical Functions

MySQL mathematical Functions

In addition to the four basic arithmetic operations addition (+), Subtraction (-), Multiplication (*) and Division (/), MySQL also has the Modulo (%) operator. This calculates the remainder left after division.

select 87 % 9; +--------+ | 87 % 9 | +--------+ | 6 | +--------+ 1 row in set (0.00 sec)

MySQL – MOD(x, y)

Displays the remainder of x divided by y, SImilar to the Modulus operator.

select MOD(37, 13); +-------------+ | MOD(37, 13) | +-------------+ | 11 | +-------------+ 1 row in set (0.00 sec)

MySQL ABS(x)

Calculates the Absolute value of number x. Thus, if x is negative its positive value is returned.

select ABS(-4.05022); +---------------+ | ABS(-4.05022) | +---------------+ | 4.05022 | +---------------+ 1 row in set (0.00 sec) select ABS(4.05022); +--------------+ | ABS(4.05022) | +--------------+ | 4.05022 | +--------------+ 1 row in set (0.00 sec)

SQL SIGN(x)

Returns 1, 0 or -1 when x is positive, zero or negative, respectively.

select SIGN(-34.22); +--------------+ | SIGN(-34.22) | +--------------+ | -1 | +--------------+ 1 row in set (0.00 sec) select SIGN(54.6); +------------+ | SIGN(54.6) | +------------+ | 1 | +------------+ 1 row in set (0.00 sec) select SIGN(0); +---------+ | SIGN(0) | +---------+ | 0 | +---------+ 1 row in set (0.00 sec)

POWER(x,y)

Calculates the value of x raised to the power of y.

select POWER(4,3); +------------+ | POWER(4,3) | +------------+ | 64.000000 | +------------+ 1 row in set (0.00 sec)

SQRT(x)

Calculates the square root of x.

select SQRT(3); +----------+ | SQRT(3) | +----------+ | 1.732051 | +----------+ 1 row in set (0.00 sec)

ROUND(x) and ROUND(x,y)

Returns the value of x rounded to the nearest integer.

Read More...

MySQL tutorial A little more on the MySQL SELECT statement

MySQL tutorial A little more on the MySQL SELECT statement

A little more on the MySQL SELECT statement

The MySQL SELECT command is something like a print or write command of other languages. You can ask it to display text strings, numeric data, the results of mathematical expressions etc.

Displaying the MySQL version number

select version(); +-----------+ | version() | +-----------+ | 3.22.32 | +-----------+ 1 row in set (0.00 sec)

Displaying the current date and time

select now(); +---------------------+ | now() | +---------------------+ | 2001-05-31 00:36:24 | +---------------------+ 1 row in set (0.00 sec)

Displaying the current Day, Month and Year

SELECT DAYOFMONTH(CURRENT_DATE); +--------------------------+ | DAYOFMONTH(CURRENT_DATE) | +--------------------------+ | 28 | +--------------------------+ 1 row in set (0.01 sec) SELECT MONTH(CURRENT_DATE); +---------------------+ | MONTH(CURRENT_DATE) | +---------------------+ | 1 | +---------------------+ 1 row in set (0.00 sec) SELECT YEAR(CURRENT_DATE); +--------------------+ | YEAR(CURRENT_DATE) | +--------------------+ | 2001 | +--------------------+ 1 row in set (0.00 sec)

Displaying text strings

select 'I Love MySQL'; +--------------+ | I Love MySQL | +--------------+ | I Love MySQL | +--------------+ 1 row in set (0.00 sec)

Obviously you can provide pseudo names for these columns using AS.

select 'Manish Sharma' as Name; +---------------+ | Name | +---------------+ | Manish Sharma | +---------------+ 1 row in set (0.00 sec)

Evaluating expressions in MySQL

select ((4 * 4) / 10 ) + 25; +----------------------+ | ((4 * 4) / 10 ) + 25 | +----------------------+ | 26.60 | +----------------------+ 1 row in set (0.00 sec)

Concatenating in MySQL

With SELECT you can concatenate values for display.

Read More...

MySQL tutorial HAVING clause

MySQL tutorial HAVING clause

HAVING clause

To list the average salary of employees in different departments (titles), we use the GROUP BY clause, as in:

select title, AVG(salary) from employee_data GROUP BY title; +----------------------------+-------------+ | title | AVG(salary) | +----------------------------+-------------+ | CEO | 200000.0000 | | Customer Service Manager | 70000.0000 | | Finance Manager | 120000.0000 | | Marketing Executive | 77333.3333 | | Multimedia Programmer | 83333.3333 | | Programmer | 75000.0000 | | Senior Marketing Executive | 120000.0000 | | Senior Programmer | 115000.0000 | | Senior Web Designer | 110000.0000 | | System Administrator | 95000.0000 | | Web Designer | 87500.0000 | +----------------------------+-------------+ 11 rows in set (0.00 sec)

Now, suppose you want to list only the departments where the average salary is more than $100000, you can’t do it, even if you assign a pseudo name to AVG(salary) column.

Read More...

MySQL tutorial Counting

MySQL tutorial Counting

Counting

The COUNT() aggregate functions counts and displays the total number of entries. For example, to count the total number of entries in the table, issue the command below.

select COUNT(*) from employee_data; +----------+ | COUNT(*) | +----------+ | 21 | +----------+ 1 row in set (0.00 sec)

As you have learnt, the * sign means "all data"

Now, let’s count the total number of employees who hold the "Programmer" title.

select COUNT(*) from employee_data where title = 'Programmer'; +----------+ | COUNT(*) | +----------+ | 4 | +----------+ 1 row in set (0.01 sec)

The MySQL GROUP BY clause

The GROUP BY clause allows us to group similar data. Thus, to list all unique titles in our table we can issue

select title from employee_data GROUP BY title; +----------------------------+ | title | +----------------------------+ | CEO | | Customer Service Manager | | Finance Manager | | Marketing Executive | | Multimedia Programmer | | Programmer | | Senior Marketing Executive | | Senior Programmer | | Senior Web Designer | | System Administrator | | Web Designer | +----------------------------+ 11 rows in set (0.01 sec)

You’ll notice that this is similar to the usage of DISTINCT, which we encountered in a previous session.

Okay, here is how you can count the number of employees with different titles.

select title, count(*) from employee_data GROUP BY title; +----------------------------+----------+ | title | count(*) | +----------------------------+----------+ | CEO | 1 | | Customer Service Manager | 1 | | Finance Manager | 1 | | Marketing Executive | 3 | | Multimedia Programmer | 3 | | Programmer | 4 | | Senior Marketing Executive | 1 | | Senior Programmer | 2 | | Senior Web Designer | 1 | | System Administrator | 2 | | Web Designer | 2 | +----------------------------+----------+ 11 rows in set (0.00 sec)

For the command above, MySQL first groups different titles and then executes count on each group.

Sorting the data in MySQL

Now, let’s find and list the number of employees holding different titles and sort them using ORDER BY.

select title, count(*) AS Number from employee_data GROUP BY title ORDER BY Number; +----------------------------+--------+ | title | Number | +----------------------------+--------+ | CEO | 1 | | Customer Service Manager | 1 | | Finance Manager | 1 | | Senior Marketing Executive | 1 | | Senior Web Designer | 1 | | Senior Programmer | 2 | | System Administrator | 2 | | Web Designer | 2 | | Marketing Executive | 3 | | Multimedia Programmer | 3 | | Programmer | 4 | +----------------------------+--------+ 11 rows in set (0.00 sec) « Previous MySQL tutorial Naming Columns   Next » MySQL tutorial HAVING clause

Posts Related to MySQL tutorial Counting

  • MySQL tutorial The DISTINCT keyword

    The DISTINCT keyword In this section of the online MySQL guide, we will look at how to select and display records from MySQL tables using ...

  • MySQL tutorial HAVING clause

    HAVING clause To list the average salary of employees in different departments (titles), we use the GROUP BY clause, as in: select title, AVG(salary) from ...

  • MySQL tutorial IN and BETWEEN

    IN and BETWEEN This section of the tutorial MySQL looks at the In and BETWEEN operators.

Read More...

MySQL tutorial Naming Columns

MySQL tutorial Naming Columns

Naming Columns

MySQL allows you to name the displayed columns. So instead of f_name or l_name etc. you can use more descriptive terms. This is achieved with AS.

select avg(salary) AS 'Average Salary' from employee_data; +----------------+ | Average Salary | +----------------+ | 95095.2381 | +----------------+ 1 row in set (0.00 sec)

Such pseudo names make will the display more clear to users. The important thing to remember here is that if you assign pseudo names that contain spaces, enclose the names in quotes. Here is another example:

select (SUM(perks)/SUM(salary) * 100) AS 'Perk Percentage' from employee_data; +-----------------+ | Perk Percentage | +-----------------+ | 19.53 | +-----------------+ 1 row in set (0.00 sec) « Previous MySQL tutorial Finding the average and sum   Next » MySQL tutorial Counting

Posts Related to MySQL tutorial Naming Columns

  • MySQL tutorial A little more on the MySQL SELECT statement

    A little more on the MySQL SELECT statement The MySQL SELECT command is something like a print or write command of other languages. You can ...

  • MySQL tutorial Finding the average and sum

    Finding the average and sum Totalling column values with MySQL SUM The SUM() aggregate function calculates the total of values in a column. You require ...

  • MySQL tutorial Querying MySQL tables assignment answers

    Possible Answers create database addressbook; OR CREATE DATABASE addressbook; Note: SQL statements are case-insensitive, though table names and database names might be sensitive to case ...

  • MySQL tutorial selecting data using conditions

    selecting data using conditions In this section of the MySQL tutorial we'll look at the format of a SELECT statement we met in the last ...

  • MySQL tutorial Querying MySQL tables

    Querying MySQL tables Our employee_data table now contains enough data for us to work with.

Read More...

MySQL tutorial Finding the average and sum

MySQL tutorial Finding the average and sum

Finding the average and sum

Totalling column values with MySQL SUM

The SUM() aggregate function calculates the total of values in a column. You require to give the column name, which should be placed inside parenthesis. Let’s see how much Bignet spends on salaries.

select SUM(salary) from employee_data; +-------------+ | SUM(salary) | +-------------+ | 1997000 | +-------------+ 1 row in set (0.00 sec)

SImilarly, we can display the total perks given to employees.

select SUM(perks) from employee_data; +------------+ | SUM(perks) | +------------+ | 390000 | +------------+ 1 row in set (0.00 sec)

How about finding the total of salaries and perks?

select sum(salary) + sum(perks) from employee_data; +-------------------------+ | sum(salary)+ sum(perks) | +-------------------------+ | 2387000 | +-------------------------+ 1 row in set (0.01 sec)

This shows a hidden gem of the SELECT command. You can add, subtract, multiply or divide values. Actually, you can write full blown arithemetic expressions. Cool!

MySQL AVG() – Finding the Average

The AVG() aggregate function is employed for calculating averages of data in columns.

select avg(age) from employee_data; +----------+ | avg(age) | +----------+ | 31.6190 | +----------+ 1 row in set (0.00 sec)

This displays the average age of employees in Bignet and the following displays the average salary.

select avg(salary) from employee_data; +-------------+ | avg(salary) | +-------------+ | 95095.2381 | +-------------+ 1 row in set (0.00 sec) « Previous MySQL tutorial Finding the minimum and maximum values   Next » MySQL tutorial Naming Columns

Posts Related to MySQL tutorial Finding the average and sum

  • MySQL tutorial Finding the minimum and maximum values

    Finding the minimum and maximum values MySQL provides inbuilt functions to find the minimum and maximum values.

Read More...

« Previous
 
Next »
DMCA.com

Adds