HOME
MYSQL
MYSQL
Introduction MYSQL
Table Create MYSQL
Retrive MYSQL Insert
MYSQL Delete
MYSQL Update
MYSQL Sort
|
MYSQL Table Create
MYSQL Retrive
In this chapter you will learn how to use SELECT statement to receive one or more columns of data from a table
The SELECT statement
To use SELECT to retrieve table data you must specify minimum two information.
What you want to select
Form where you want to select
We will start with simple MYSQL SELECT statement
SELECT student_name from student ;
The meaning of the statement
SELECT column from table
The above statement uses SELECT statement to retrieve a single column called student_name from a table student
Retrieving multiple column form table
To retrieve multiple columns from table, the same select statement is used
For example
SELECT student_name,student_age,student_marks from student;
Retrieving all columns
To retrieve all the column in a table use the following syntax
SELECT * from student
The wildcard (*) specifies all the column in a table
Using MYSQL select statement with PHP |
<?
$db=mysql_connect("freewebs.dot5hostingmysql.com", "USERNAME", "PASSWORD") or die("could not connect");
$sel=mysql_select_db(“DATABASE", $db) or die ("could not connect");
$result=mysql_query("select * from event") or die("could not connect");
?> |
Using MYSQL SELECT statement with ASP |
<%
' Open database
Dim Conn, RS
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={MySql ODBC 3.51 Driver}; Server=freewebs.dot5hostingmysql.com; database=slogin; uid=username; pwd=password; option=3;"
dim rslogincheck,strsql
set rslogincheck=server.createobject("ADOdb.CONNECTION")
strsql="select student_name,student_age from student;"
%>
|
using MYSQL SELECT statement with JSP |
<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://freewebs.dot5hostingmysql.com/login?user=USENAME;password=PASS";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
rs = statement.executeQuery("select * from student");
%>
What is SQL?
SQL is an abbreviation for Structured Query Language. SQL is a language designed mainly for communicating with databases. SQL is easy to learn. The statements are all made up of descriptive English word. SQL is designed to do only one work that is communicating with database in a simple and efficient way.
|
|
|