$sql1 = "SELECT indexer, user_id, friends_id AS from_id, //Change result name to from_id 'friend' AS type, //For each record found add a result called 'type' containing 'friend' todays_date FROM friends WHERE friends_id = $user_id"; Outputting Results As A Comma Separated List (Or any character separated) $QueryString = "SELECT CONCAT_WS(',',SomeColumnName0,SomeColumnName1,SomeColumnName2) FROM MyTable WHERE SomeColumn = 12"; //"CONCAT_WS(','," […]
All posts by
Case Sensitivity
Select is not case sensitive by default SELECT * FROM myTable WHERE ‘something’ = ‘Something’ = 1 To make it case sensitive use a select with binary SELECT * FROM myTable WHERE BINARY ‘something’ = ‘Something’ //or SELECT * FROM myTable WHERE ‘something’ = BINARY ‘Something’ = 0
JOIN to get results from 2 tables
Using JOIN to get results from two tables This is PHP4 Code! Example 1 Example 2 Using JOIN to get results from three tables This is PHP4 Code! Example 1 Using GROUP BY To Get One Row Per Match This is PHP4 Code! Note – when using GROUP BY, if you also use ORDER BY […]
Reload page
Reload the current page Form reloads current page Link reloads current page Reload current page but with post values stripped Using javascript Periodic Refresh
Curved Corners
Images border-radius: 4px 4px 4px 4px;
.UPDATE general
Object Oriented Style How many rows were affected Procedural Style Maths Operations In Update Queries Add text to an existing text field
Columns Data Types
Quick Data Types List (For a more in depth description see below) Numeric BOOL Use TINYINT BIT The BIT data type is used to store bit-field values. A type of BIT(M) enables storage of M-bit values. M can range from 1 to 64. (Not universally supported) INT A normal-sized integer that can be signed or unsigned. […]
.SELECT General
Object Oriented Style Does Record Exist Simple Get A Result Alternative with check for no result Get Each Row Returned Procedural Style Does Record Exist Simple Get A Result Get Each Row Returned Get Number Of Rows Returned Get Specific Columns Get each field as a variable named as the field Using OR Arguments Putting All […]
.DELETE General
Object Oriented Style Procedural Style Delete old records by date Delete table Truncate is the fastest method to delete all data in a table as the table is dropped and re-creaed.
.INSERT General
Object Oriented Style Get Auto ID Of New Record Procedural Style Get Auto ID Of New Record The mysqli_insert_id() function returns the ID generated by a query on a table with a column having the AUTO_INCREMENT attribute. If the last query wasn’t an INSERT or UPDATE statement or if the modified table does not have a […]