May 2006


MySQL Examples31 May 2006 10:09 am

A quick query structure to retrive the last row entry to a logging table, in this case there can be multiple rows that would return the same id and date but I want only the very last so this query works well.

CODE:
  1. $query="SELECT a.user_id, a.access_date FROM superlog a
  2. WHERE a.access_date = (SELECT MAX(b.access_date)
  3.             FROM superlog b
  4.             WHERE a.user_id=b.user_id)
  5. AND ip = CONVERT( _utf8 '10.10.10.10' USING latin1 )
  6. COLLATE latin1_swedish_ci;

MySQL Examples08 May 2006 10:43 am

The Drop command is used to delete all the records in a table using the table name as shown below:

Syntax:

$dropSQL=("DROP tblName");

Example

CODE:
  1. $dropSQL=("DROP tblstudent");

MySQL Examples08 May 2006 10:42 am

The Update command is used to update the field values using conditions. This is done using 'SET' and the fieldnames to assign new values to them.

Syntax:

$updateSQL=("UPDATE Tblname SET (fieldname1=value1,fieldname2=value2,...) WHERE fldstudid=IdNumber");

Example:

CODE:
  1. $updateSQL=("UPDATE Tblstudent SET (fldstudName=siva,fldstudmark=100) WHERE fldstudid=2");

MySQL Examples08 May 2006 10:42 am

The Insert command is used to insert records into a table. The values are assigned to the field names as shown below:

Syntax:

$insertSQL=("INSERT INTO tblname(fieldname1,fieldname2..) VALUES(value1,value2,...) ");

Example

CODE:
  1. $insertSQL=("INSERT INTO Tblstudent(fldstudName,fldstudmark)VALUES(Baskar,75) ");

MySQL Examples08 May 2006 10:40 am

The Delete command is used to delete the records from a table using conditions as shown below:

Syntax:

$deleteSQL=("DELETE * FROM tablename WHERE condition");

Example:

CODE:
  1. $deleteSQL=("DELETE * FROM tblstudent WHERE fldstudid=2");

Next Page »


Mortgages - Homeowner Loans - Life Insurance - Flights - Consolidation Loans
X10 Home Security|Dakar's Photos
Listed on BlogShares