9 articles MySQL

MySQL: Exclude ‘group by’ group if field A in any row has value B with “Natural Join”

Querying databases get a little tricky when you have a stack of records associated with another table, perhaps a master table of accounts, and you're trying to filter out values that would exclude the results from another group of results. In this example below, we are getting a list of organization IDs for all countries…

Finding missing records of the right joined table in MySQL

Let's say you have two database tables that are supposed to have the same record IDs. Perhaps they contain different data but share the same ID -- for this example, we call it "user_id". This query will select only the missing records of the right joined table. Since the "right" table is joining the…

Copying MySQL databases at the command line is fast and easy

Copying your MySQL databases from the command line, if you have privileges is easy, a lot easier than going into PHP MyAdmin and hoping the "Copy Database" function is available and it doesn't time out... Here's how you can copy databases to a remote server: Here how you copy MySQL database to a local…

PHP Developers: MySQLi & PDO forcing errors helpful for debugging queries when accessing private or protected isolated classes

Sometimes you don't have much control over other people's code but your code must interact with it.  That's one of the issues you will encounter when you work in a collaborative coding environment and you're all developing code the proper way -- there's encapsulation so you know your code is isolated to only what you…

Mysql PDO standard insert (persist) of data to a table with placeholders to protect from MySQL injection attacks

This is a much more secure way to insert records and prevent MySQL injection.  This assumes that $this-conn is your MySQLi PDO database connection object that you've already initialized: Please note that a lot of the PHP snippets on this site assume you have some level of PHP experience.  I use this site as…
  • Page 1 of 2
  • 1
  • 2