Basic MySQL Command Tutorial



Posted in TechnologySoftware

Introduction: Basic MySQL Command Tutorial

About: Occupation: Tech Support

Basic MySQL Command Tutorial:

  1. SQL query using a pattern:
    Select * from '[table name]' where [field name] like '[text]%'
    The '%' sign is a wildcard; eg: Eliz%
  2. SQL query using exact words:
    Select * from '[table name]' where [field name] = '[text]'
    Eg: 'Elizabeth Smith'
  3. SQL query using pattern and 2 wildcards:
    Select * from '[table name]' where [field name] = '[text]%[text]%'
    Eg: 'Eliz%Sm%'
  4. SQL query using multiple exact words:
    Select * from '[table name]' where [field name] ='[search text]' or [field name] = '[search text]'
    EG: zip='10001' or zip='10002'
  5. This SQL command changes a field or fields in a table based on a pattern matching another field.
    The basic command is an UPDATE:
    UPDATE [table] SET [field1]='[new data]', [field2]='[new data]' WHERE [any field in database] = '[data]'
    An example:
    UPDATE representativetable SET title='Assemblyman', name='Rafael Espinal', WHERE district = 'A054'
    The above command looks for district A054 and changes the title and name fields.



    • Space Challenge

      Space Challenge
    • Science of Cooking

      Science of Cooking
    • Spotless Contest

      Spotless Contest

    We have a be nice policy.
    Please be positive and constructive.