Category Archives: MySQL

Select Records using PHP MySQL Select Statement

online tutorilas




You can use SELECT statement to select data from a database. Syntax SELECT column_name(s) FROM table_name To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection. For Example: The following example selects all the data stored in the “student” table (The * character selects all the data in the table): <?php $con = mysql_connect(“localhost”,”username”,”password”); if (!$con) { die(‘Could not connect: ‘ . […]

Sorting using MySQL ORDER BY Statement

Sorting using PHP MySQL ORDER BY Statement




We use Sorting using MySQL  Order by statement in a recordset.The ORDER BY keyword sort the records in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword. SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC You can sort on multiple columns, and you can sort different columns in different directions This query would return me the results ordered by the species in the order I need and then sort […]

Create Database and Tables in PHP MySQL

php-mysql




As We know database holds one or multiple tables. Here in this post you will learn how create database tables in Mysql Create a Database We use the CREATE DATABASE statement to create a database in MySQL. Syntax CREATE DATABASE database_name To get PHP to execute the MYSQL statement we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection. For Example The following example creates a database called “school_database”: <?php […]

Mysql Full Text Search – Mysql

mysql-full-text-search




In this post you’ll learn how to build a basic full-text search engine using PHP and MySQL. What is full text search? The full-text search in mysql allows you to quick and very accurate search for single or multiple keywords from multiple columns. It does this by using an index on the columns that you want to search. There are a few limitations that you should know. Indexed columns can only be TEXT, MySQL does not by default index words […]

Mysql interview questions

mysql-question




Q 1- How to setup admin user for MYSQL ? Ans: Login as super user ‘root’ in mysql and execute the following commands. mysql> use mysql; mysql> create user ‘test’@’%’ identified by ‘test’; mysql> grant all on *.* to ‘test’@’%’ with grant option; mysql> flush privileges; Q 2- What types of privileges are there in MySQL ? Ans: There are 4 types of privileges. i). Global privileges like *.* (all hosts connecting to Mysql db server) Example: GRANT SELECT, INSERT […]

Mysql Join Syntax

mysql-join-syntax




SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables. This means everything you have learned so far can be applied after you’ve created this new, joined table. How Does a Join Work?  A join works through the use of keys. Continuing our example, our supplier table contains a column designated as the supplier_id. This column is configured as the primary key (for details on primary keys see Database […]

Top 6 rules to build Solid MySQL AND PHP Applications

6_golden_rules_php




PHP & MYSQL are the those preferred technologies for building web applications, since they provide a way to build web applications rapidly. However, sometimes it leads to code that is hard to maintain , doesn’t scale well and perform poorly. And here there are several golden rules that helps you to build rock-solid applications. 1) Do not Trust your Users’ Input A first golden rules that you should bear in mind is to never write code that trusts customer input. […]

MySQL Best Practices

MySQL Best Practices




Database operations often tend to be the main bottleneck for most web applications today. It’s not only the DBA’s (database administrators) that have to worry about these performance issues. We as programmers need to do our part by structuring tables properly, writing optimized queries and better code. Here are some MySQL optimization techniques for programmers.