Guides:SQL/How do I/Show and Find Records in a Table

From CoderGuide

Jump to: navigation, search

Return to the SQL How Do I Index

Finding/displaying of records is done using the SELECT keyword. In addition to SELECT, you can use WHERE/LIKE keywords to locate specific entries.

SELECT takes the following format

SELECT * FROM tabe_name;
SELECT column1,column2,colum6,column3 FROM tabe_name WHERE somecell='nothing';
SELECT * FROM table_name WHERE something='nothing';
SELECT * FROM table_name WHERE something LIKE '%this%';
SELECT * FROM table_name WHERE void IS NULL;

The % is a wild card, similar to * in regular expressions. "this%" would match a row with a cell's content that starts with this, and any number of characters after. Of course, you can also \G or \g instead of ;, though \G will likely be more useful to you than \g. \g' and ; produce a normal output for the list as a table, \G will output one cell per line, which is useful if cells contain a lot of text data that will make your results not display neatly on your screen

Personal tools