Introduction: Basic MySQL Command Tutorial

Picture of Basic MySQL Command Tutorial

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.

Comments

About This Instructable

455views

7favorites

License:

Bio: Occupation: Tech Support
More by matt392:Q-Tip Paint PenReplace Letters on Computer Keyboard (or Make Bigger Letters) With Nail PolishMulti-bit Screwdriver From PVC Pipe
Add instructable to: