Writing SQL Statements – Tips And Tricks For The Beginner

In case you are not an experienced programmer and know just enough about SQL to make you very curious about knowing more, these tips and tricks for the SQL beginner may help you with your latest SQL project.

Assuming that you know some of the basics of writing SQL queries, these tips can alleviate some of your struggles with getting the query results that you are really looking for.

Basic query explanations

SELECT * FROM table_name WHERE Name LIKE ‘%card’

The results will show all products that have a name that ends in card. That % sign is the wild card and can be put in front of a word or part of a word, after the word or even before and after a word. So if you want to show all products that are cards, this would come in handy.

Adding modifiers to your SQL statement

SELECT * FROM table_name WHERE Name LIKE ‘%Disney%’

AND Name LIKE ‘%label%’;

Let’s say you want to show all products that are Disney products and are address labels. You would use the above SQL statement.

Using AND multiple times in one query

SELECT * FROM table_name WHERE Name ‘%card%’

AND Name ‘%label%’

AND Company=’Checks To Go’

AND Price Using AND to get more specific results

AND can also be used to get more detailed information and is sometimes followed

by (column1=’widgetgreen’ or column2=’widgetblue’ or column3=’widgetpink’)

AND (column1=’card’ or column2=’boohaahaas’ or column3=’minihahas’)

Your statement might look like this:

SELECT * FROM table_name WHERE Name ‘%card%’

AND

(column1=’widgetgreen’

or column2=’widgetblue’

or column3=’widgetpink’

)

AND

(column1=’card’

or column2=’boohaahaas’

or column3=’minihahas’

);

Getting limited results using SQL statements can help your website become easy to navigate and find the products your customers are looking for. This information will help anyone beginning to learn how to write SQL statements produce better website content.