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

Read More

JOIN to get results from 2 tables

This is PHP4 Code! Using JOIN to get results from two tables Example 1 $result = @mysql_fetch_array(@mysql_query(" SELECT * FROM group_invitations JOIN member_profile ON member_profile.user_id = group_invitations.user_id WHERE indexer = $indexer ")); Example 2 $query = @mysql_query(" SELECT * FROM group_profile AS GP JOIN group_membership AS GM ON GM.group_id = GP.indexer WHERE (member_id = $user_id […]

Read More

.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 […]

Read More

Querying Across Tables

This is PHP4 Code! Using IN Within A Normal SELECT Query You can select from within another tables results really easily like this: SqlCommand1->CommandText = "SELECT ProjectId \ FROM tblMyTable1 \ WHERE ProjectIsActive='TRUE' AND ProjectId IN (SELECT ProjectId FROM tblMyTable2 WHERE ProjectUsersAll='TRUE' OR [email protected]) \ ORDER BY ProjectStartDate DESC"; Simple Find Name From Another Table […]

Read More

ORDER BY

Sorting Results Use this To Sort On Multiple Values ORDER BY With $wpdb->prepare ORDER BY and %s does not work with $wpdb->prepare, in our tests the following order by gets ignored: Whereas this works as expected. So it seems that $wpdb->prepare() adding single quotes around the inserted name field causes it to break. Date Order […]

Read More