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 results 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 Address LIKE '%label%';
Let’s say you want to show all results that are names with Disney and address with label. You would use the above SQL statement.
Using AND multiple times in one query
Using AND to get more specific results.
SELECT * FROM table_name WHERE Name '%card%' AND Name '%label%' AND Company='Mc Donald' AND Price
AND can also be used to get more detailed information and is sometimes followed by
(column1='value1' or column2='value2' or column3='value3') AND (column1='label1' or column2='label2' or column3='label3')
Your statement might look like this:
SELECT * FROM table_name WHERE Name '%card%' AND (column1='value1' or column2='value2' or column3='value3') AND (column1='label1' or column2='label2' or column3='label3');
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.