join/limit

  • If it has the same name in both tables, we can use

       USING (CustomerId)

syntax. If the name differs, say we had CustomerId and CId, we would use the
       ON Customers.CustomerId = Reservations.CId syntax
  • The inner join selects only those records from database tables that have matching values;

The INNER keyword can be omitted.

  • The LEFT OUTER JOIN returns all values from the left table, even if there is no match with the right table. In such rows, there will be NULL values. In other words, left outer join returns all the values from the left table, plus matched values from the right table. Note, that the OUTER keyword can be omitted.
  • for the names in select, usually using table.column, but if there is only one table has such name, you can omit the table, just use select column, rather than specifying table.column.
  • Limit – MySQL Command

    Definition: Limit is used to limit your MySQL query results to those that fall within a specified range. You can use it to show the first X number of results, or to show a range from X – Y results. It is phrased as Limit X, Y and included at the end of your query. X is the starting point (remember the first record is 0) and Y is the duration (how many records to display).
    Examples:
     SELECT * FROM `your_table` LIMIT 0, 10 
    
    This will display the first 10 results from the database.
    

    and

     SELECT * FROM `your_table` LIMIT 5, 5
    
    This will show records 6, 7, 8, 9, and 10
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s