SQL Strategies and Tactics
August 17, 2010
The IN Thing
By Michael Marr
Staying in fashion is often a tough proposition. If you're one of the unfortunate ones that do attempt to keep up, you likely end up with an overpriced and overstocked wardrobe. Some fashions, however, never die, and thus can continue to be used at your discretion. Likewise, your database can become stuffed to the seams, and there may be situations where you want to return a result if it matches not only a single value, but also any from a host of values.

For instance, you might have a list of ids and you only want to return rows that have an id in that list. One approach is an endless string of conditions:

SELECT * FROM t1 WHERE

t1.id = 1 OR t1.id = 3 OR t1.id = 5 OR t1.id = 7

OR t1.id = 11 OR t1.id = 13 OR t1.id = 17

Continue Reading
Interested in contributing to the SQL community?
Can you write expert articles and tutorials designed to help SQL users of any skill level implement successful SQL systems and practices? If so, we are looking for you. Contact techwriters@ientry.com.
Today's Top Videos:
Living without Facebook, Twitter, and IM – Is It Possible?
Facebook, Twitter, and Instant Messaging have become natural parts of our everyday life. They also play key roles in many businesses. But is there a downside? Can they dominate too much time?
How Eye Tracking Endorses Universal Search
Eye tracking is fascinating to think about in and of itself. Interestingly enough, Shari Thurow of Omni Marketing Interactive spoke with WebProNews about eye tracking research.
Using Sitemaps to Push Content Effectively
There are many ways in which people can push content including sitemaps, RSS, and XML. Each of these methods provide vast opportunities for getting written text, video, podcasts...
Recent Articles:
Data Integrity With Foreign Keys
In relational database design, we rely on keys in one table to relate to the primary keys of another. The InnoDB engine takes this concept and supplies the Foreign Key constraint to keep our relationships healthy and strong. It's truly a relationship miracle-worker. Eat your heart out, Dr. Phil.

We might have some tables that look something like this:

mysql>DESCRIBE widgets;

Read More...

Sorting By Count(*)
The other day, I was working on a fairly database-centric project, when I came across a problem I had never come across before. It seemed like such a simple task that I could not fathom why I could not write the query to get what I wanted. What I needed to do was to choose only the...
Read More...
How To Dupe Duplicate Rows In Three Easy...
Repetitive information goes against good database design, and thus is reason enough to find and remove duplicate values. However, when utilizing an UNIQUE key or other types of indexes, duplications actually break or prevent statements from...
Read More...
Cooking With SQL: Short And Sweet
One of my fondest childhood memories revolves around my Grandmother's cooking. She was able to take out store bought hot dogs, boil them in a pot of water, and serve them up on piece of bread for many of my childhood lunches. Likewise, one my...
Read More...
Other iEntry Business Resources:
- WebProNews.com
- Jayde.com
- MarketingNewz.com
- SalesNewz.com
- CareerNewz.com
- InvestNewz.com
- eCommNewz.com
- WebsiteNotes.com
- AdvertisingDay.com
iEntry
footer
-- SQLProNews is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2010 iEntry, Inc. All Rights Reserved Privacy Policy Legal